From nobody Wed May 15 03:39:09 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+88929+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+88929+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011879; cv=none; d=zohomail.com; s=zohoarc; b=nfbXqia2W/ZI4D9/5BuHRI+WWJ1Lb3/cb5Qs822NbIjncWwoKN52EZLKCgTV/MQRR95TjtgPz+xsR9JHDEDV34pk2xqyyFIdHXSbi90hk9hS3aWS8HBZmeq3CXKXqYXS+FjBCmGUwK/AKmvkilWVoTyM00xnMYF4OGy7CJOifSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011879; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=LG9w2an+VW9Oq2J7m+q2tN+LtoNy/XCNjGcuYhyW30A=; b=P+ODTvNjVGkRZP3ed81noXVQ56Go71oxvhmrSXXa4pYo2rjxxrs70P6T+bLKAmohjVE2O6GMlea7R2+pnWirJYV8M+UTthFLPSt/p8GXS7j8Xcfoi0AX0cf1NT/sPhuvaNCvljS8Yz9LT43lPmrsj02mFsIqmGPGv3tGMlGMTwY= 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+88929+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 1650011879777194.42999338630318; Fri, 15 Apr 2022 01:37:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id srudYY1788612xlwu4z4Cym2; Fri, 15 Apr 2022 01:37:59 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5202.1650011878251661812 for ; Fri, 15 Apr 2022 01:37:58 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563796" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563796" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:53 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990455" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:51 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 1/8] IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit Date: Fri, 15 Apr 2022 16:37:36 +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: l6RTUtvoGW5EWHaMQZvYl9Brx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011879; bh=1dWWtDGL60s1+OBr1Qqgf/YSMI/fAgbU/oHqXZ0Lm8U=; h=Cc:Date:From:Reply-To:Subject:To; b=HVFMN/Y6V5dTqE0hmqKfVNgE4xYeCQnOjLhRT8nfpQSt15K5o7I2X3KQpUSlSal9Aet Al4ZAgaNfHmdhhWdpmD7e8hALIxiiXzS5CJf9fuXRZ3CC0XLap71LFy2hDtI+U8GR6BHz DgDIZLOJV0wmEMwu/XNG3JW01P/s29nfEH0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011880365100003 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, SwapStack and PEI_CORE_ENTRY. 2.Treat both MAX_ADDRESS and MAX_UINT32 as invalid address for FSP global data in FspApiCallingCheck(). 3.Changed AsmReadEsp to AsmReadStackPointer. 4.Changed the type of the return value of AsmReadStackPointer from UINT32 to UINTN. 5.Changed the type of TemporaryMemoryBase, PermenentMemoryBase and BootLoaderStack from UINT32 to UINTN. 6.Some type casting to pointers are UINT32. Changed them to UINTN to accommodate both IA32 and X64. 7.Corrected some typos. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c | 3 ++- IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm | 10 +++++----- IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm | 12 ++++++------ IntelFsp2Pkg/FspSecCore/SecFsp.c | 10 +++++----- IntelFsp2Pkg/FspSecCore/SecFsp.h | 4 ++-- IntelFsp2Pkg/FspSecCore/SecFspApiChk.c | 10 +++++----- IntelFsp2Pkg/FspSecCore/SecMain.c | 10 +++++----- IntelFsp2Pkg/FspSecCore/SecMain.h | 20 +++++++++++-----= ---- .../BaseFspSwitchStackLib/FspSwitchStackLib.c | 3 ++- .../SecFspSecPlatformLibNull/Ia32/Flat32.nasm | 4 ++-- 10 files changed, 45 insertions(+), 41 deletions(-) diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c b/IntelFsp2Pk= g/FspNotifyPhase/FspNotifyPhasePeim.c index 88f5540fef..c3ba9f168c 100644 --- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c +++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c @@ -1,7 +1,7 @@ /** @file Source file for FSP notify phase PEI module =20 - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved. + Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -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..d6bbf9cc75 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm @@ -1,7 +1,7 @@ ;; @file ; Provide read ESP function ; -; Copyright (c) 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ;; ;-------------------------------------------------------------------------= ----- @@ -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..5cb2424bc8 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm @@ -1,6 +1,6 @@ ;-------------------------------------------------------------------------= ----- ; -; Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Abstract: @@ -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..04b43c10d0 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -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..41931a33dd 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -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..e22a88cc84 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c +++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -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 MAX_ADDRESS) || ((= UINTN)FspData =3D=3D MAX_UINT32)) { 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 MAX_ADDRESS) && ((UINTN)FspData !=3D MAX_UINT= 32)) { 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 MAX_ADDRESS) || ((= UINTN)FspData =3D=3D MAX_UINT32)) { 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 MAX_ADDRESS) || ((= UINTN)FspData =3D=3D MAX_UINT32)) { 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..8effe2225c 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.c +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -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..3dddbbee5e 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.h +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -23,9 +23,11 @@ #include #include =20 -typedef VOID (*PEI_CORE_ENTRY) ( \ - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \ - IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \ +typedef +VOID +(EFIAPI *PEI_CORE_ENTRY) ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList ); =20 typedef struct _SEC_IDT_TABLE { @@ -51,8 +53,8 @@ typedef struct _SEC_IDT_TABLE { VOID EFIAPI SecSwitchStack ( - IN UINT32 TemporaryMemoryBase, - IN UINT32 PermenentMemoryBase + IN UINTN TemporaryMemoryBase, + IN UINTN PermenentMemoryBase ); =20 /** @@ -104,7 +106,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 +129,9 @@ ProcessLibraryConstructorList ( @return value of esp. =20 **/ -UINT32 +UINTN EFIAPI -AsmReadEsp ( +AsmReadStackPointer ( VOID ); =20 diff --git a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/FspSwitchStackLib.c= b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/FspSwitchStackLib.c index dae4e27172..69a021f42b 100644 --- a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/FspSwitchStackLib.c +++ b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/FspSwitchStackLib.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -21,6 +21,7 @@ =20 **/ UINTN +EFIAPI SwapStack ( IN UINTN NewStack ) diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm= b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm index aef7f96d1d..95d015d928 100644 --- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm @@ -2,7 +2,7 @@ ; This is the code that goes from real-mode to protected mode. ; It consumes the reset vector, configures the stack. ; -; Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ;; =20 @@ -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 (#88929): https://edk2.groups.io/g/devel/message/88929 Mute This Topic: https://groups.io/mt/90482848/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 Wed May 15 03:39:09 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+88930+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+88930+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011880; cv=none; d=zohomail.com; s=zohoarc; b=Ki2OHWHHcv7ZnGqQHeypzDH8qR1GVNQiNNkMz1qNGAdXHjnwscwp1gEUcaEDSG5LuUmCAoZTk+vOEULa4wCspKuwcx255faTbNROVF5sSSvGwbV69EJUcAVUA+XsPoPIaIHqRC44tMTIh+Z1iTPA4rFk6se6KNxzKUSzp3hRQ1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011880; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=TBq5KZaxgBj73STPJXZ1LVw8KOX9LIgXrL/aj1N/GMY=; b=HHSjs1VLFpIbXNBO50dIfRXFnreOwSEWG7PF/OKNAVWf2cxasc7HtUglq7KUDGOzaXHsDUGWw9KGP4KfkgEpDVVAf8QnnGrysGxRkPnW3/NrHoj452jFXf7at1h6gN+1zVapFLC7umFO3ns7jyIvLq1bzjmfOi917WjZftY/FPY= 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+88930+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 1650011880184415.42773126526527; Fri, 15 Apr 2022 01:38:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HsAaYY1788612xiLu8RaUexT; Fri, 15 Apr 2022 01:37:59 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5202.1650011878251661812 for ; Fri, 15 Apr 2022 01:37:59 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563802" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563802" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:55 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990461" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:53 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 2/8] IntelFsp2Pkg: Add FSPx_ARCH2_UPD support for X64 Date: Fri, 15 Apr 2022 16:37:37 +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: Mkho9KgkcoJYf13gyMK1vu0rx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011879; bh=C5wwfZUuzPVL+hmReZSHRpiymwOvft6dfe9ZGOBlF/M=; h=Cc:Date:From:Reply-To:Subject:To; b=HUcZkqXE/B7ndY7rRsMXm9ugV9XnuuQ5+l+dRab1pKrnzGj5Krte+jZQeaECoghRnPL bPC4ya/iuEqUzeuU1mWW4hl+VvhaDrFM4WX2fgAN0/zWS19PD+9uB02tnIkjXok73HRJv zxwI0AJIaI2Y7rbQLN855H17rquFeHp6wBo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011882340100016 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 FSPx_ARCH2_UPD structures which support both IA32 and X64. 2.Added FSPx_UPD_COMMON_FSP24 structures. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm | 32 +++++- IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm | 98 ++++++++++++++--- IntelFsp2Pkg/Include/FspEas/FspApi.h | 139 +++++++++++++++++++++= +++- IntelFsp2Pkg/Tools/GenCfgOpt.py | 7 +- 4 files changed, 252 insertions(+), 24 deletions(-) diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm b/IntelFsp2Pkg/= FspSecCore/Ia32/FspApiEntryM.nasm index e7261b41cd..5dada2af54 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm @@ -1,7 +1,7 @@ ;; @file ; Provide FSP API entry points. ; -; Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ;; =20 @@ -32,6 +32,24 @@ struc FSPM_UPD_COMMON .size: endstruc =20 +struc FSPM_UPD_COMMON_FSP24 + ; FSP_UPD_HEADER { + .FspUpdHeader: resd 8 + ; } + ; FSPM_ARCH2_UPD { + .Revision: resb 1 + .Reserved: resb 3 + .Length resd 1 + .StackBase: resq 1 + .StackSize: resq 1 + .BootLoaderTolumSize: resd 1 + .BootMode: resd 1 + .FspEventHandler resq 1 + .Reserved1: resb 24 + ; } + .size: +endstruc + ; ; Following functions will be provided in C ; @@ -124,12 +142,22 @@ ASM_PFX(FspApiCommonContinue): pop eax =20 FspStackSetup: + mov ecx, [edx + FSPM_UPD_COMMON.Revision] + cmp ecx, 3 + jae FspmUpdCommon2 + ; ; StackBase =3D temp memory base, StackSize =3D temp memory size ; mov edi, [edx + FSPM_UPD_COMMON.StackBase] mov ecx, [edx + FSPM_UPD_COMMON.StackSize] + jmp ChkFspHeapSize + +FspmUpdCommon2: + mov edi, [edx + FSPM_UPD_COMMON_FSP24.StackBase] + mov ecx, [edx + FSPM_UPD_COMMON_FSP24.StackSize] =20 +ChkFspHeapSize: ; ; Keep using bootloader stack if heap size % is 0 ; @@ -219,7 +247,7 @@ exit: global ASM_PFX(FspPeiCoreEntryOff) ASM_PFX(FspPeiCoreEntryOff): ; - ; This value will be pached by the build script + ; This value will be patched by the build script ; DD 0x12345678 =20 diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm b/IntelFsp2Pkg/= FspSecCore/Ia32/FspApiEntryT.nasm index 7fd3d6d843..61030a843b 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm @@ -1,7 +1,7 @@ ;; @file ; Provide FSP API entry points. ; -; Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ;; =20 @@ -84,8 +84,10 @@ struc LoadMicrocodeParamsFsp22 .FspUpdHeaderRevision: resb 1 .FspUpdHeaderReserved: resb 23 ; } - ; FSPT_ARCH_UPD{ - .FsptArchUpd: resd 8 + ; FSPT_ARCH_UPD { + .FsptArchRevision: resb 1 + .FsptArchReserved: resb 3 + .FsptArchUpd: resd 7 ; } ; FSPT_CORE_UPD { .MicrocodeCodeAddr: resd 1 @@ -96,6 +98,28 @@ struc LoadMicrocodeParamsFsp22 .size: endstruc =20 +struc LoadMicrocodeParamsFsp24 + ; FSP_UPD_HEADER { + .FspUpdHeaderSignature: resd 2 + .FspUpdHeaderRevision: resb 1 + .FspUpdHeaderReserved: resb 23 + ; } + ; FSPT_ARCH2_UPD { + .FsptArchRevision: resb 1 + .FsptArchReserved: resb 3 + .FsptArchLength: resd 1 + .FspDebugHandler resq 1 + .FsptArchUpd: resd 4 + ; } + ; FSPT_CORE_UPD { + .MicrocodeCodeAddr: resq 1 + .MicrocodeCodeSize: resq 1 + .CodeRegionBase: resq 1 + .CodeRegionSize: resq 1 + ; } + .size: +endstruc + ; ; Define SSE macros ; @@ -172,9 +196,9 @@ ASM_PFX(LoadMicrocodeDefault): ; Executed by SBSP and NBSP ; Beginning of microcode update region starts on paragraph boundary =20 - ; ; ; Save return address to EBP + ; movd ebp, mm7 =20 cmp esp, 0 @@ -188,8 +212,12 @@ ASM_PFX(LoadMicrocodeDefault): ; and report error if size is less than 2k ; first check UPD header revision cmp byte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2 - jae Fsp22UpdHeader + jb Fsp20UpdHeader + cmp byte [esp + LoadMicrocodeParamsFsp22.FsptArchRevision], 2 + je Fsp24UpdHeader + jmp Fsp22UpdHeader =20 +Fsp20UpdHeader: ; UPD structure is compliant with FSP spec 2.0/2.1 mov eax, dword [esp + LoadMicrocodeParams.MicrocodeCodeSize] cmp eax, 0 @@ -213,6 +241,19 @@ Fsp22UpdHeader: mov esi, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr] cmp esi, 0 jnz CheckMainHeader + jmp ParamError + +Fsp24UpdHeader: + ; UPD structure is compliant with FSP spec 2.4 + mov eax, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] + cmp eax, 0 + jz Exit2 + cmp eax, 0800h + jl ParamError + + mov esi, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] + cmp esi, 0 + jnz CheckMainHeader =20 ParamError: mov eax, 080000002h @@ -308,9 +349,13 @@ AdvanceFixedSize: =20 CheckAddress: ; Check UPD header revision - cmp byte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2 - jae Fsp22UpdHeader1 + cmp byte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2 + jb Fsp20UpdHeader1 + cmp byte [esp + LoadMicrocodeParamsFsp22.FsptArchRevision], 2 + je Fsp24UpdHeader1; + jmp Fsp22UpdHeader1 =20 +Fsp20UpdHeader1: ; UPD structure is compliant with FSP spec 2.0/2.1 ; Is automatic size detection ? mov eax, dword [esp + LoadMicrocodeParams.MicrocodeCodeSize] @@ -336,6 +381,19 @@ Fsp22UpdHeader1: jae Done ;Jif address is outside of microcode region jmp CheckMainHeader =20 +Fsp24UpdHeader1: + ; UPD structure is compliant with FSP spec 2.4 + ; Is automatic size detection ? + mov eax, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] + cmp eax, 0ffffffffh + jz LoadMicrocodeDefault4 + + ; Address >=3D microcode region address + microcode region size? + add eax, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] + cmp esi, eax + jae Done ;Jif address is outside of microcode region + jmp CheckMainHeader + LoadMicrocodeDefault4: ; Is valid Microcode start point ? cmp dword [esi + MicrocodeHdr.MicrocodeHdrVersion], 0ffffffffh @@ -351,7 +409,7 @@ LoadCheck: mov eax, 1 cpuid mov ecx, MSR_IA32_BIOS_SIGN_ID - rdmsr ; Get current microcode signature + rdmsr ; Get current microcode signature =20 ; Verify this microcode update is not already loaded cmp dword [esi + MicrocodeHdr.MicrocodeHdrRevision], edx @@ -405,8 +463,12 @@ ASM_PFX(EstablishStackFsp): =20 ; check UPD structure revision (edx + 8) cmp byte [edx + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2 - jae Fsp22UpdHeader2 + jb Fsp20UpdHeader2 + cmp byte [esp + LoadMicrocodeParamsFsp22.FsptArchRevision], 2 + je Fsp24UpdHeader2 + jmp Fsp22UpdHeader2 =20 +Fsp20UpdHeader2: ; UPD structure is compliant with FSP spec 2.0/2.1 push dword [edx + LoadMicrocodeParams.CodeRegionSize] ; Code si= ze sizeof(FSPT_UPD_COMMON) + 12 push dword [edx + LoadMicrocodeParams.CodeRegionBase] ; Code ba= se sizeof(FSPT_UPD_COMMON) + 8 @@ -420,6 +482,14 @@ Fsp22UpdHeader2: push dword [edx + LoadMicrocodeParamsFsp22.CodeRegionBase] ; Co= de base sizeof(FSPT_UPD_COMMON) + 8 push dword [edx + LoadMicrocodeParamsFsp22.MicrocodeCodeSize] ; Mi= crocode size sizeof(FSPT_UPD_COMMON) + 4 push dword [edx + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr] ; Mi= crocode base sizeof(FSPT_UPD_COMMON) + 0 + jmp ContinueAfterUpdPush + +Fsp24UpdHeader2: + ; UPD structure is compliant with FSP spec 2.4 + push dword [edx + LoadMicrocodeParamsFsp24.CodeRegionSize] ; Co= de size sizeof(FSPT_UPD_COMMON) + 24 + push dword [edx + LoadMicrocodeParamsFsp24.CodeRegionBase] ; Co= de base sizeof(FSPT_UPD_COMMON) + 16 + push dword [edx + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] ; Mi= crocode size sizeof(FSPT_UPD_COMMON) + 8 + push dword [edx + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] ; Mi= crocode base sizeof(FSPT_UPD_COMMON) + 0 =20 ContinueAfterUpdPush: ; @@ -517,13 +587,13 @@ ASM_PFX(TempRamInitApi): cmp eax, 0 jnz TempRamInitExit =20 - LXMMN xmm6, eax, 3 ;Restore microcode status if no CAR init error = from ECX-SLOT 3 in xmm6. + LXMMN xmm6, eax, 3 ;Restore microcode status if no CAR init error f= rom ECX-SLOT 3 in xmm6. =20 TempRamInitExit: - mov bl, al ; save al data in bl - mov al, 07Fh ; API exit postcode 7f - out 080h, al - mov al, bl ; restore al data from bl + mov bl, al ; save al data in bl + mov al, 07Fh ; API exit postcode 7f + out 080h, al + mov al, bl ; restore al data from bl =20 ; ; Load EBP, EBX, ESI, EDI & ESP from XMM7 & XMM6 diff --git a/IntelFsp2Pkg/Include/FspEas/FspApi.h b/IntelFsp2Pkg/Include/Fs= pEas/FspApi.h index 794f94dc7a..b36bc2b9ae 100644 --- a/IntelFsp2Pkg/Include/FspEas/FspApi.h +++ b/IntelFsp2Pkg/Include/FspEas/FspApi.h @@ -2,7 +2,7 @@ Intel FSP API definition from Intel Firmware Support Package External Architecture Specification v2.0 - v2.2 =20 - Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -112,12 +112,12 @@ typedef struct { /// typedef struct { /// - /// Revision Revision of the structure is 1 for this version of the spec= ification. + /// Revision of the structure is 1 for this version of the specification. /// UINT8 Revision; UINT8 Reserved[3]; /// - /// Length Length of the structure in bytes. The current value for this = field is 32. + /// Length of the structure in bytes. The current value for this field i= s 32. /// UINT32 Length; /// @@ -128,6 +128,27 @@ typedef struct { UINT8 Reserved1[20]; } FSPT_ARCH_UPD; =20 +/// +/// FSPT_ARCH2_UPD Configuration. +/// +typedef struct { + /// + /// Revision of the structure is 2 for this version of the specification. + /// + UINT8 Revision; + UINT8 Reserved[3]; + /// + /// Length of the structure in bytes. The current value for this field i= s 32. + /// + UINT32 Length; + /// + /// FspDebugHandler Optional debug handler for the bootloader to receive= debug messages + /// occurring during FSP execution. + /// + EFI_PHYSICAL_ADDRESS FspDebugHandler; + UINT8 Reserved1[16]; +} FSPT_ARCH2_UPD; + /// /// FSPM_ARCH_UPD Configuration. /// @@ -169,14 +190,57 @@ typedef struct { UINT8 Reserved1[4]; } FSPM_ARCH_UPD; =20 +/// +/// FSPM_ARCH2_UPD Configuration. +/// +typedef struct { + /// + /// Revision of the structure is 3 for this version of the specification. + /// + UINT8 Revision; + UINT8 Reserved[3]; + /// + /// Length of the structure in bytes. The current value for this field i= s 64. + /// + UINT32 Length; + /// + /// Pointer to the temporary stack base address to be + /// consumed inside FspMemoryInit() API. + /// + EFI_PHYSICAL_ADDRESS StackBase; + /// + /// Temporary stack size to be consumed inside + /// FspMemoryInit() API. + /// + UINT64 StackSize; + /// + /// Size of memory to be reserved by FSP below "top + /// of low usable memory" for bootloader usage. + /// + UINT32 BootLoaderTolumSize; + /// + /// Current boot mode. + /// + UINT32 BootMode; + /// + /// Optional event handler for the bootloader to be informed of events o= ccurring during FSP execution. + /// This value is only valid if Revision is >=3D 2. + /// + EFI_PHYSICAL_ADDRESS FspEventHandler; + UINT8 Reserved1[24]; +} FSPM_ARCH2_UPD; + +/// +/// FSPS_ARCH_UPD Configuration. +/// typedef struct { /// - /// Revision Revision of the structure is 1 for this version of the spec= ification. + /// Revision of the structure is 1 for this version of the specification. /// UINT8 Revision; UINT8 Reserved[3]; /// - /// Length Length of the structure in bytes. The current value for this = field is 32. + /// Length of the structure in bytes. The current value for this field i= s 32. /// UINT32 Length; /// @@ -195,6 +259,27 @@ typedef struct { UINT8 Reserved1[19]; } FSPS_ARCH_UPD; =20 +/// +/// FSPS_ARCH2_UPD Configuration. +/// +typedef struct { + /// + /// Revision of the structure is 2 for this version of the specification. + /// + UINT8 Revision; + UINT8 Reserved[3]; + /// + /// Length of the structure in bytes. The current value for this field i= s 32. + /// + UINT32 Length; + /// + /// FspEventHandler Optional event handler for the bootloader to be info= rmed of events + /// occurring during FSP execution. + /// + EFI_PHYSICAL_ADDRESS FspEventHandler; + UINT8 Reserved1[16]; +} FSPS_ARCH2_UPD; + /// /// FSPT_UPD_COMMON Configuration. /// @@ -220,6 +305,21 @@ typedef struct { FSPT_ARCH_UPD FsptArchUpd; } FSPT_UPD_COMMON_FSP22; =20 +/// +/// FSPT_UPD_COMMON Configuration for FSP spec. 2.4 and above. +/// +typedef struct { + /// + /// FSP_UPD_HEADER Configuration. + /// + FSP_UPD_HEADER FspUpdHeader; + + /// + /// FSPT_ARCH2_UPD Configuration. + /// + FSPT_ARCH2_UPD FsptArchUpd; +} FSPT_UPD_COMMON_FSP24; + /// /// FSPM_UPD_COMMON Configuration. /// @@ -234,6 +334,20 @@ typedef struct { FSPM_ARCH_UPD FspmArchUpd; } FSPM_UPD_COMMON; =20 +/// +/// FSPM_UPD_COMMON Configuration for FSP spec. 2.4 and above. +/// +typedef struct { + /// + /// FSP_UPD_HEADER Configuration. + /// + FSP_UPD_HEADER FspUpdHeader; + /// + /// FSPM_ARCH2_UPD Configuration. + /// + FSPM_ARCH2_UPD FspmArchUpd; +} FSPM_UPD_COMMON_FSP24; + /// /// FSPS_UPD_COMMON Configuration. /// @@ -259,6 +373,21 @@ typedef struct { FSPS_ARCH_UPD FspsArchUpd; } FSPS_UPD_COMMON_FSP22; =20 +/// +/// FSPS_UPD_COMMON Configuration for FSP spec. 2.4 and above. +/// +typedef struct { + /// + /// FSP_UPD_HEADER Configuration. + /// + FSP_UPD_HEADER FspUpdHeader; + + /// + /// FSPS_ARCH2_UPD Configuration. + /// + FSPS_ARCH2_UPD FspsArchUpd; +} FSPS_UPD_COMMON_FSP24; + /// /// Enumeration of FSP_INIT_PHASE for NOTIFY_PHASE. /// diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py b/IntelFsp2Pkg/Tools/GenCfgOpt= .py index 714b2d8b1a..c4fb1f1bb2 100644 --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py @@ -1,6 +1,6 @@ ## @ GenCfgOpt.py # -# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -1398,6 +1398,7 @@ EndList UpdConfigCheck =3D ['FSP_T', 'FSP_M', 'FSP_S'] # FSP_X_CONFIG, FS= P_X_TEST_CONFIG, FSP_X_RESTRICTED_CONFIG UpdSignatureCheck =3D ['FSPT_UPD_SIGNATURE', 'FSPM_UPD_SIGNATURE',= 'FSPS_UPD_SIGNATURE'] ExcludedSpecificUpd =3D ['FSPT_ARCH_UPD', 'FSPM_ARCH_UPD', 'FSPS_A= RCH_UPD'] + ExcludedSpecificUpd1 =3D ['FSPT_ARCH2_UPD', 'FSPM_ARCH2_UPD', 'FSP= S_ARCH2_UPD'] =20 IncLines =3D [] if InputHeaderFile !=3D '': @@ -1452,7 +1453,7 @@ EndList if Match: StartIndex =3D Index - 1 Match =3D re.match("}\s([_A-Z0-9]+);", Line) - if Match and (UpdRegionCheck[item] in Match.group(1) or Up= dConfigCheck[item] in Match.group(1)) and (ExcludedSpecificUpd[item] not in= Match.group(1)): + if Match and (UpdRegionCheck[item] in Match.group(1) or Up= dConfigCheck[item] in Match.group(1)) and (ExcludedSpecificUpd[item] not in= Match.group(1)) and (ExcludedSpecificUpd1[item] not in Match.group(1)): EndIndex =3D Index StructStart.append(StartIndex) StructEnd.append(EndIndex) @@ -1695,7 +1696,7 @@ EndList =20 =20 def Usage(): - print ("GenCfgOpt Version 0.56") + print ("GenCfgOpt Version 0.57") print ("Usage:") print (" GenCfgOpt UPDTXT PlatformDscFile BuildFvDir = [-D Macros]") print (" GenCfgOpt HEADER PlatformDscFile BuildFvDir InputHFile = [-D Macros]") --=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 (#88930): https://edk2.groups.io/g/devel/message/88930 Mute This Topic: https://groups.io/mt/90482849/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 Wed May 15 03:39:09 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+88932+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+88932+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011881; cv=none; d=zohomail.com; s=zohoarc; b=oIhrqxVwv/u6w997a503seh0RPLbhAbSqWtkZDqLUBOmF+9PHNbHhoHcJKVquMtjzNwfyPZTQFogSTTIbzkmWNBvxOceMrZH6v0G0UOqn7F8tdNwHrEa3cwhq513llNyB+IwVFVd/f2RQ857yo8A35Zk2CZeyRPNLxmE4+YcvO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011881; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=PutWQvX7syH0ZevXVscxEc9Ans3aFK36c3dzAmkWrLU=; b=fpxSDPIs/khiUTfxj1TNSvDH3rrqb0wEJygACIVbhfcMA5hvCpcyN/yKpnrZ9dpVXgXAlCz73dTiS+nst+9hEUoPz0tEARWS/J3sdKyPjGHNDFayKbBhO0MyUfSkGlkQ745Bkv8uv27ljBTvy5W+XyOdtZ0MeebTcbcFxz1ck+g= 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+88932+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 1650011881587464.46460703808737; Fri, 15 Apr 2022 01:38:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Yg0sYY1788612x9hBZlxL1bj; Fri, 15 Apr 2022 01:38:00 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5203.1650011879374670285 for ; Fri, 15 Apr 2022 01:38:00 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563805" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563805" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:57 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990467" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:55 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 3/8] IntelFsp2Pkg: Update FSP_GLOBAL_DATA and FSP_PLAT_DATA for X64 Date: Fri, 15 Apr 2022 16:37:38 +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: CghTXTBaWP1HY7me8Sa50l43x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011880; bh=k+z1CoSaCcx8QSso1P+T8uPd3uyVFkksIXYN8SKaG2E=; h=Cc:Date:From:Reply-To:Subject:To; b=UCjsUuAAgbLkXqORSj2eQpcK0fuO61Wqf4ORg4vUh62+KSii0O6MevmuZUP9RpnlZYP T39nkLVojP5gYP2v7W3ak7mSQwxkYZPSMEUaNyHcIim7KV3zF0S1Nmccrrxb4LqutraaD 5zV6EOmzbKuGcvNZBIdj66iN62TsmqgwRZY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011882324100015 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 Updated FSP_GLOBAL_DATA and FSP_PLAT_DATA structures to support both IA32 and X64. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- IntelFsp2Pkg/FspSecCore/SecFsp.c | 2 +- IntelFsp2Pkg/Include/FspGlobalData.h | 53 +++++++++++++++++++++++++-------= ---- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.c index 04b43c10d0..7fde6e7f41 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c @@ -130,7 +130,7 @@ FspGlobalDataInit ( ZeroMem ((VOID *)PeiFspData, sizeof (FSP_GLOBAL_DATA)); =20 PeiFspData->Signature =3D FSP_GLOBAL_DATA_SIGNATURE; - PeiFspData->Version =3D 0; + PeiFspData->Version =3D FSP_GLOBAL_DATA_VERSION; PeiFspData->CoreStack =3D BootLoaderStack; PeiFspData->PerfIdx =3D 2; PeiFspData->PerfSig =3D FSP_PERFORMANCE_DATA_SIGNATURE; diff --git a/IntelFsp2Pkg/Include/FspGlobalData.h b/IntelFsp2Pkg/Include/Fs= pGlobalData.h index 2b534075ae..445540abfa 100644 --- a/IntelFsp2Pkg/Include/FspGlobalData.h +++ b/IntelFsp2Pkg/Include/FspGlobalData.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -10,8 +10,9 @@ =20 #include =20 -#define FSP_IN_API_MODE 0 -#define FSP_IN_DISPATCH_MODE 1 +#define FSP_IN_API_MODE 0 +#define FSP_IN_DISPATCH_MODE 1 +#define FSP_GLOBAL_DATA_VERSION 1 =20 #pragma pack(1) =20 @@ -28,10 +29,11 @@ typedef enum { =20 typedef struct { VOID *DataPtr; - UINT32 MicrocodeRegionBase; - UINT32 MicrocodeRegionSize; - UINT32 CodeRegionBase; - UINT32 CodeRegionSize; + UINTN MicrocodeRegionBase; + UINTN MicrocodeRegionSize; + UINTN CodeRegionBase; + UINTN CodeRegionSize; + UINTN Reserved; } FSP_PLAT_DATA; =20 #define FSP_GLOBAL_DATA_SIGNATURE SIGNATURE_32 ('F', 'S', 'P', 'D') @@ -42,15 +44,15 @@ typedef struct { UINT32 Signature; UINT8 Version; UINT8 Reserved1[3]; + /// + /// Offset 0x08 + /// UINTN CoreStack; + UINTN Reserved2; + /// + /// IA32: Offset 0x10; X64: Offset 0x18 + /// UINT32 StatusCode; - UINT32 Reserved2[8]; - FSP_PLAT_DATA PlatformData; - FSP_INFO_HEADER *FspInfoHeader; - VOID *UpdDataPtr; - VOID *TempRamInitUpdPtr; - VOID *MemoryInitUpdPtr; - VOID *SiliconInitUpdPtr; UINT8 ApiIdx; /// /// 0: FSP in API mode; 1: FSP in DISPATCH mode @@ -60,15 +62,34 @@ typedef struct { UINT8 Reserved3; UINT32 NumberOfPhases; UINT32 PhasesExecuted; + UINT32 Reserved4[8]; /// + /// IA32: Offset 0x40; X64: Offset 0x48 + /// Start of UINTN and pointer section + /// All UINTN and pointer members must be put in this section + /// except CoreStack and Reserved2. In addition, the number of + /// UINTN and pointer members must be even for natural alignment + /// in both IA32 and X64. + /// + FSP_PLAT_DATA PlatformData; + VOID *TempRamInitUpdPtr; + VOID *MemoryInitUpdPtr; + VOID *SiliconInitUpdPtr; + /// + /// IA32: Offset 0x64; X64: Offset 0x90 /// To store function parameters pointer /// so it can be retrieved after stack switched. /// VOID *FunctionParameterPtr; - UINT8 Reserved4[16]; + FSP_INFO_HEADER *FspInfoHeader; + VOID *UpdDataPtr; + /// + /// End of UINTN and pointer section + /// + UINT8 Reserved5[16]; UINT32 PerfSig; UINT16 PerfLen; - UINT16 Reserved5; + UINT16 Reserved6; UINT32 PerfIdx; UINT64 PerfData[32]; } FSP_GLOBAL_DATA; --=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 (#88932): https://edk2.groups.io/g/devel/message/88932 Mute This Topic: https://groups.io/mt/90482851/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 Wed May 15 03:39:09 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+88931+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+88931+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011880; cv=none; d=zohomail.com; s=zohoarc; b=hDRvCOsw0f/wzjourSVqB+dXWUQxfkeK+PZeQN0aeMY9aagBKKyEj/t9JDmmPYReHZAOfVF7bII110F+OFcCUL7JOoR7Dj6hLnLb/IM6ZIN8Lzjui8D4RYpIQeO35KGO7vSuLwhC+6CdUdAVtd5qR1HyUfEN4OaHgEwMJ2klkz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011880; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=qIim5UlUSF2bNjXxxUsAicr1nT184/2HlyUW6Bk8/T0=; b=FCig3lKZp3FqUom/d7P0iPMnPOqYTLT8bPvQEjwFLzkCsNiDZAnRO+evX8Zyah/pN7KBNpeALJrMXbS6dyZN0eKAq/wZTzPSWZbzjNxGoSAYG+3ybu6bYF/sEnOn1DHl1eI7KMzreGYxdEWyQFlZdfxDYldJL5lY6DIhxR/rs8Q= 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+88931+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 1650011880785836.7756376289598; Fri, 15 Apr 2022 01:38:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EgjxYY1788612xbOqdxJFapi; Fri, 15 Apr 2022 01:38:00 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5202.1650011878251661812 for ; Fri, 15 Apr 2022 01:37:59 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563807" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563807" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:59 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990470" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:57 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 4/8] IntelFsp2Pkg: FspSecCore support for X64 Date: Fri, 15 Apr 2022 16:37:39 +0800 Message-Id: <5e52b78d5b39a50c232378c94c53442d02486b91.1650011731.git.ted.kuo@intel.com> 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: imO6lw7mEdOZkNvU3Y40OxYFx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011880; bh=uLrGvjQATbHWEPjpqadD8vaCZfvO6dNUV8nN/pT2Rhw=; h=Cc:Date:From:Reply-To:Subject:To; b=CovBZCz3X/nmxjrKINPslxUsLMRXrzq4ORDI5dbWIxQ9cRsCxptvFMbqR4hn+EhbuqU XFbd8bpzKUKqNPI9oUjT89PFJ1Qs59J8Z5uKiAPepYd8Sw0iJ815GC4iZCZEBegBhjN+e jDwFnUtPg8Fw101ZDRBtrVJRiTlR9R8mQvY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011882381100020 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 FspSecCore support for X64. 2.Bumped FSP header revision to 7 to indicate FSP 64bit is supported. 3.Corrected few typos. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf | 10 +- IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 11 +- IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf | 10 +- IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf | 12 +- .../FspSecCore/Ia32/FspApiEntryCommon.nasm | 6 +- IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm | 103 +++++ IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm | 76 ++++ IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm | 271 +++++++++++ IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm | 67 +++ IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm | 495 +++++++++++++++++= ++++ IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm | 34 ++ IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc | 11 + IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm | 22 + IntelFsp2Pkg/FspSecCore/X64/Stack.nasm | 73 +++ IntelFsp2Pkg/Include/Guid/FspHeaderFile.h | 16 +- IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc | 284 ++++++++++++ .../Library/BaseFspCommonLib/FspCommonLib.c | 6 +- .../Library/BaseFspSwitchStackLib/X64/Stack.nasm | 5 +- 18 files changed, 1493 insertions(+), 19 deletions(-) create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc create mode 100644 IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Stack.nasm create mode 100644 IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc diff --git a/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf b/IntelFsp2Pkg/FspSe= cCore/Fsp22SecCoreS.inf index 0a24eb2a8b..4a67388ddf 100644 --- a/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf +++ b/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf @@ -1,7 +1,7 @@ ## @file # Sec Core for FSP to support MultiPhase (SeparatePhase) SiInitialization. # -# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -17,7 +17,7 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] @@ -30,6 +30,12 @@ Ia32/FspApiEntryCommon.nasm Ia32/FspHelper.nasm =20 +[Sources.X64] + X64/Stack.nasm + X64/Fsp22ApiEntryS.nasm + X64/FspApiEntryCommon.nasm + X64/FspHelper.nasm + [Binaries.Ia32] RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC =20 diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf b/IntelFsp2Pkg/FspSecC= ore/FspSecCoreM.inf index 7b05cae641..a7fc07dc61 100644 --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf @@ -1,7 +1,7 @@ ## @file # Sec Core for FSP # -# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -17,7 +17,7 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] @@ -34,6 +34,13 @@ Ia32/FspHelper.nasm Ia32/ReadEsp.nasm =20 +[Sources.X64] + X64/Stack.nasm + X64/FspApiEntryM.nasm + X64/FspApiEntryCommon.nasm + X64/FspHelper.nasm + X64/ReadRsp.nasm + [Binaries.Ia32] RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC =20 diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf b/IntelFsp2Pkg/FspSecC= ore/FspSecCoreS.inf index 1d9c2554d1..fb80c0e339 100644 --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf @@ -1,7 +1,7 @@ ## @file # Sec Core for FSP # -# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -17,7 +17,7 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] @@ -30,6 +30,12 @@ Ia32/FspApiEntryCommon.nasm Ia32/FspHelper.nasm =20 +[Sources.X64] + X64/Stack.nasm + X64/FspApiEntryS.nasm + X64/FspApiEntryCommon.nasm + X64/FspHelper.nasm + [Binaries.Ia32] RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC =20 diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf b/IntelFsp2Pkg/FspSecC= ore/FspSecCoreT.inf index 664bde5678..e5a6eaa164 100644 --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf @@ -1,7 +1,7 @@ ## @file # Sec Core for FSP # -# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -17,17 +17,19 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 -[Sources] - - [Sources.IA32] Ia32/Stack.nasm Ia32/FspApiEntryT.nasm Ia32/FspHelper.nasm =20 +[Sources.X64] + X64/Stack.nasm + X64/FspApiEntryT.nasm + X64/FspHelper.nasm + [Binaries.Ia32] RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC =20 diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm b/IntelFsp= 2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm index 26ae7d9fd3..8d8deba28a 100644 --- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm +++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm @@ -1,12 +1,14 @@ ;; @file ; Provide FSP API entry points. ; -; Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ;; =20 SECTION .text =20 +STACK_SAVED_EAX_OFFSET EQU 4 * 7 ; size of a general purpose regis= ter * eax index + ; ; Following functions will be provided in C ; @@ -52,7 +54,7 @@ FspApiCommon1: add esp, 8 cmp eax, 0 jz FspApiCommon2 - mov dword [esp + (4 * 7)], eax + mov dword [esp + STACK_SAVED_EAX_OFFSET], eax popad exit: ret diff --git a/IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm b/IntelFsp2Pkg= /FspSecCore/X64/Fsp22ApiEntryS.nasm new file mode 100644 index 0000000000..c739793a39 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm @@ -0,0 +1,103 @@ +;; @file +; Provide FSP API entry points. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + + SECTION .text + +; +; Following functions will be provided in C +; +extern ASM_PFX(FspApiCommon) +extern ASM_PFX(FspMultiPhaseSiInitApiHandler) + +STACK_SAVED_RAX_OFFSET EQU 8 * 7 ; size of a general purpose regis= ter * rax index + +;-------------------------------------------------------------------------= --- +; NotifyPhase API +; +; This FSP API will notify the FSP about the different phases in the boot +; process +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(NotifyPhaseApi) +ASM_PFX(NotifyPhaseApi): + mov eax, 2 ; FSP_API_INDEX.NotifyPhaseApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspSiliconInit API +; +; This FSP API initializes the CPU and the chipset including the IO +; controllers in the chipset to enable normal operation of these devices. +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspSiliconInitApi) +ASM_PFX(FspSiliconInitApi): + mov eax, 5 ; FSP_API_INDEX.FspSiliconInitApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspMultiPhaseSiInitApi API +; +; This FSP API provides multi-phase silicon initialization, which brings g= reater +; modularity beyond the existing FspSiliconInit() API. +; Increased modularity is achieved by adding an extra API to FSP-S. +; This allows the bootloader to add board specific initialization steps th= roughout +; the SiliconInit flow as needed. +; +;-------------------------------------------------------------------------= --- + +%include "PushPopRegsNasm.inc" + +global ASM_PFX(FspMultiPhaseSiInitApi) +ASM_PFX(FspMultiPhaseSiInitApi): + mov eax, 6 ; FSP_API_INDEX.FspMultiPhaseSiInitApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspApiCommonContinue API +; +; This is the FSP API common entry point to resume the FSP execution +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspApiCommonContinue) +ASM_PFX(FspApiCommonContinue): + ; + ; Handle FspMultiPhaseSiInitApiIndex API + ; + cmp eax, 6 + jnz NotMultiPhaseSiInitApi + + PUSHA_64 + mov rdx, rcx ; move ApiParam to rdx + mov rcx, rax ; move ApiIdx to rcx + call ASM_PFX(FspMultiPhaseSiInitApiHandler) + mov qword [rsp + STACK_SAVED_RAX_OFFSET], rax + POPA_64 + ret + +NotMultiPhaseSiInitApi: + jmp $ + ret + +;-------------------------------------------------------------------------= --- +; TempRamInit API +; +; Empty function for WHOLEARCHIVE build option +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(TempRamInitApi) +ASM_PFX(TempRamInitApi): + jmp $ + ret + +;-------------------------------------------------------------------------= --- +; Module Entrypoint API +;-------------------------------------------------------------------------= --- +global ASM_PFX(_ModuleEntryPoint) +ASM_PFX(_ModuleEntryPoint): + jmp $ + diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm b/IntelFsp2= Pkg/FspSecCore/X64/FspApiEntryCommon.nasm new file mode 100644 index 0000000000..718e672e02 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm @@ -0,0 +1,76 @@ +;; @file +; Provide FSP API entry points. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + + SECTION .text + +%include "PushPopRegsNasm.inc" + +STACK_SAVED_RAX_OFFSET EQU 8 * 7 ; size of a general purpose regis= ter * rax index + +; +; Following functions will be provided in C +; +extern ASM_PFX(Loader2PeiSwitchStack) +extern ASM_PFX(FspApiCallingCheck) + +; +; Following functions will be provided in ASM +; +extern ASM_PFX(FspApiCommonContinue) +extern ASM_PFX(AsmGetFspInfoHeader) + +;-------------------------------------------------------------------------= --- +; FspApiCommon API +; +; This is the FSP API common entry point to resume the FSP execution +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspApiCommon) +ASM_PFX(FspApiCommon): + ; + ; RAX holds the API index + ; + + ; + ; Stack must be ready + ; + push rax + add rsp, 8 + cmp rax, [rsp - 8] + jz FspApiCommon1 + mov rax, 08000000000000003h + jmp exit + +FspApiCommon1: + ; + ; Verify the calling condition + ; + PUSHA_64 + mov rdx, rcx ; move ApiParam to rdx + mov rcx, rax ; move ApiIdx to rcx + call ASM_PFX(FspApiCallingCheck) + cmp rax, 0 + jz FspApiCommon2 + mov [rsp + STACK_SAVED_RAX_OFFSET], rax + POPA_64 +exit: + ret + +FspApiCommon2: + POPA_64 + cmp rax, 3 ; FspMemoryInit API + jz FspApiCommon3 + + cmp rax, 6 ; FspMultiPhaseSiInitApiIndex API + jz FspApiCommon3 + + call ASM_PFX(AsmGetFspInfoHeader) + jmp ASM_PFX(Loader2PeiSwitchStack) + +FspApiCommon3: + jmp ASM_PFX(FspApiCommonContinue) + diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm b/IntelFsp2Pkg/F= spSecCore/X64/FspApiEntryM.nasm new file mode 100644 index 0000000000..4d965e14a7 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm @@ -0,0 +1,271 @@ +;; @file +; Provide FSP API entry points. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + + SECTION .text + +%include "PushPopRegsNasm.inc" + +; +; Following are fixed PCDs +; +extern ASM_PFX(PcdGet8 (PcdFspHeapSizePercentage)) + +struc FSPM_UPD_COMMON_FSP24 + ; FSP_UPD_HEADER { + .FspUpdHeader: resd 8 + ; } + ; FSPM_ARCH2_UPD { + .Revision: resb 1 + .Reserved: resb 3 + .Length resd 1 + .StackBase: resq 1 + .StackSize: resq 1 + .BootLoaderTolumSize: resd 1 + .BootMode: resd 1 + .FspEventHandler resq 1 + .Reserved1: resb 24 + ; } + .size: +endstruc + +; +; Following functions will be provided in C +; +extern ASM_PFX(SecStartup) +extern ASM_PFX(FspApiCommon) + +; +; Following functions will be provided in PlatformSecLib +; +extern ASM_PFX(AsmGetFspBaseAddress) +extern ASM_PFX(AsmGetFspInfoHeader) + +FSP_HEADER_IMGBASE_OFFSET EQU 1Ch +FSP_HEADER_CFGREG_OFFSET EQU 24h + +;-------------------------------------------------------------------------= --- +; FspMemoryInit API +; +; This FSP API is called after TempRamInit and initializes the memory. +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspMemoryInitApi) +ASM_PFX(FspMemoryInitApi): + mov eax, 3 ; FSP_API_INDEX.FspMemoryInitApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; TempRamExitApi API +; +; This API tears down temporary RAM +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(TempRamExitApi) +ASM_PFX(TempRamExitApi): + mov eax, 4 ; FSP_API_INDEX.TempRamExitApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspApiCommonContinue API +; +; This is the FSP API common entry point to resume the FSP execution +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspApiCommonContinue) +ASM_PFX(FspApiCommonContinue): + ; + ; RAX holds the API index + ; Push RDX and RCX to form CONTEXT_STACK_64 + ; + push rdx ; Push a QWORD data for stack alignment + push rdx ; Push API Parameter2 on stack + push rcx ; Push API Parameter1 on stack + + ; + ; FspMemoryInit API setup the initial stack frame + ; + + ; + ; Place holder to store the FspInfoHeader pointer + ; + push rax + + ; + ; Update the FspInfoHeader pointer + ; + push rax + call ASM_PFX(AsmGetFspInfoHeader) + mov [rsp + 8], rax + pop rax + + ; + ; Create a Task Frame in the stack for the Boot Loader + ; + pushfq + cli + PUSHA_64 + + ; Reserve 16 bytes for IDT save/restore + sub rsp, 16 + sidt [rsp] + + ; Get Stackbase and StackSize from FSPM_UPD Param + mov rdx, rcx ; Put FSPM_UPD Param to r= dx + cmp rdx, 0 + jnz FspStackSetup + + ; Get UPD default values if FspmUpdDataPtr (ApiParam1) is null + xchg rbx, rax + call ASM_PFX(AsmGetFspInfoHeader) + mov edx, [rax + FSP_HEADER_IMGBASE_OFFSET] + add edx, [rax + FSP_HEADER_CFGREG_OFFSET] + xchg rbx, rax + +FspStackSetup: + mov cl, [rdx + FSPM_UPD_COMMON_FSP24.Revision] + cmp cl, 3 + jae FspmUpdCommonFsp24 + + mov rax, 08000000000000002h ; RETURN_INVALID_PARAMETER + sub rsp, 0b8h + ret + +FspmUpdCommonFsp24: + ; + ; StackBase =3D temp memory base, StackSize =3D temp memory size + ; + mov rdi, [rdx + FSPM_UPD_COMMON_FSP24.StackBase] + mov ecx, [rdx + FSPM_UPD_COMMON_FSP24.StackSize] + + ; + ; Keep using bootloader stack if heap size % is 0 + ; + mov rbx, ASM_PFX(PcdGet8 (PcdFspHeapSizePercentage)) + mov bl, BYTE [rbx] + cmp bl, 0 + jz SkipStackSwitch + + ; + ; Set up a dedicated temp ram stack for FSP if FSP heap size % doesn't e= qual 0 + ; + add rdi, rcx + ; + ; Switch to new FSP stack + ; + xchg rdi, rsp ; Exchange rdi and rsp, r= di will be assigned to the current rsp pointer and rsp will be Stack base += Stack size + +SkipStackSwitch: + ; + ; If heap size % is 0: + ; EDI is FSPM_UPD_COMMON_FSP24.StackBase and will hold ESP later (boot= loader stack pointer) + ; ECX is FSPM_UPD_COMMON_FSP24.StackSize + ; ESP is boot loader stack pointer (no stack switch) + ; BL is 0 to indicate no stack switch (EBX will hold FSPM_UPD_COMMON_= FSP24.StackBase later) + ; + ; If heap size % is not 0 + ; EDI is boot loader stack pointer + ; ECX is FSPM_UPD_COMMON_FSP24.StackSize + ; ESP is new stack (FSPM_UPD_COMMON_FSP24.StackBase + FSPM_UPD_COMMON_= FSP24.StackSize) + ; BL is NOT 0 to indicate stack has switched + ; + cmp bl, 0 + jnz StackHasBeenSwitched + + mov rbx, rdi ; Put FSPM_UPD_COMMON_FSP= 24.StackBase to rbx as temp memory base + mov rdi, rsp ; Put boot loader stack p= ointer to rdi + jmp StackSetupDone + +StackHasBeenSwitched: + mov rbx, rsp ; Put Stack base + Stack = size in ebx + sub rbx, rcx ; Stack base + Stack size= - Stack size as temp memory base + +StackSetupDone: + + ; + ; Per X64 calling convention, make sure RSP is 16-byte aligned. + ; + mov rdx, rsp + and rdx, 0fh + sub rsp, rdx + + ; + ; Pass the API Idx to SecStartup + ; + push rax + + ; + ; Pass the BootLoader stack to SecStartup + ; + push rdi + + ; + ; Pass BFV into the PEI Core + ; It uses relative address to calculate the actual boot FV base + ; For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and + ; PcdFspAreaBaseAddress are the same. For FSP with multiple FVs, + ; they are different. The code below can handle both cases. + ; + call ASM_PFX(AsmGetFspBaseAddress) + mov r8, rax + + ; + ; Pass entry point of the PEI core + ; + call ASM_PFX(AsmGetPeiCoreOffset) + lea r9, [r8 + rax] + + ; + ; Pass stack base and size into the PEI Core + ; + mov rcx, rcx + mov rdx, rbx + + ; + ; Pass Control into the PEI Core + ; RCX =3D SizeOfRam, RDX =3D TempRamBase, R8 =3D BFV, R9 =3D PeiCoreEntr= y, Last 1 Stack =3D BL stack, Last 2 Stack =3D API index + ; According to X64 calling convention, caller has to allocate 32 bytes a= s a shadow store on call stack right before + ; calling the function. + ; + sub rsp, 20h + call ASM_PFX(SecStartup) + add rsp, 20h +exit: + ret + +global ASM_PFX(FspPeiCoreEntryOff) +ASM_PFX(FspPeiCoreEntryOff): + ; + ; This value will be patched by the build script + ; + DD 0x12345678 + +global ASM_PFX(AsmGetPeiCoreOffset) +ASM_PFX(AsmGetPeiCoreOffset): + push rbx + mov rbx, ASM_PFX(FspPeiCoreEntryOff) + mov eax, dword[ebx] + pop rbx + ret + +;-------------------------------------------------------------------------= --- +; TempRamInit API +; +; Empty function for WHOLEARCHIVE build option +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(TempRamInitApi) +ASM_PFX(TempRamInitApi): + jmp $ + ret + +;-------------------------------------------------------------------------= --- +; Module Entrypoint API +;-------------------------------------------------------------------------= --- +global ASM_PFX(_ModuleEntryPoint) +ASM_PFX(_ModuleEntryPoint): + jmp $ + diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm b/IntelFsp2Pkg/F= spSecCore/X64/FspApiEntryS.nasm new file mode 100644 index 0000000000..f863ef0078 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm @@ -0,0 +1,67 @@ +;; @file +; Provide FSP API entry points. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + + SECTION .text + +; +; Following functions will be provided in C +; +extern ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; NotifyPhase API +; +; This FSP API will notify the FSP about the different phases in the boot +; process +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(NotifyPhaseApi) +ASM_PFX(NotifyPhaseApi): + mov eax, 2 ; FSP_API_INDEX.NotifyPhaseApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspSiliconInit API +; +; This FSP API initializes the CPU and the chipset including the IO +; controllers in the chipset to enable normal operation of these devices. +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspSiliconInitApi) +ASM_PFX(FspSiliconInitApi): + mov eax, 5 ; FSP_API_INDEX.FspSiliconInitApiIndex + jmp ASM_PFX(FspApiCommon) + +;-------------------------------------------------------------------------= --- +; FspApiCommonContinue API +; +; This is the FSP API common entry point to resume the FSP execution +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(FspApiCommonContinue) +ASM_PFX(FspApiCommonContinue): + jmp $ + ret + +;-------------------------------------------------------------------------= --- +; TempRamInit API +; +; Empty function for WHOLEARCHIVE build option +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(TempRamInitApi) +ASM_PFX(TempRamInitApi): + jmp $ + ret + +;-------------------------------------------------------------------------= --- +; Module Entrypoint API +;-------------------------------------------------------------------------= --- +global ASM_PFX(_ModuleEntryPoint) +ASM_PFX(_ModuleEntryPoint): + jmp $ + diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm b/IntelFsp2Pkg/F= spSecCore/X64/FspApiEntryT.nasm new file mode 100644 index 0000000000..a9f5f28ed7 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm @@ -0,0 +1,495 @@ +;; @file +; Provide FSP API entry points. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + + SECTION .text + +%include "SaveRestoreSseAvxNasm.inc" +%include "MicrocodeLoadNasm.inc" + +; +; Following are fixed PCDs +; +extern ASM_PFX(PcdGet32 (PcdTemporaryRamBase)) +extern ASM_PFX(PcdGet32 (PcdTemporaryRamSize)) +extern ASM_PFX(PcdGet32 (PcdFspReservedBufferSize)) + +; +; Following functions will be provided in PlatformSecLib +; +extern ASM_PFX(AsmGetFspBaseAddress) +extern ASM_PFX(AsmGetFspInfoHeader) +;extern ASM_PFX(LoadMicrocode) ; @todo: needs a weak implementation +extern ASM_PFX(SecPlatformInit) ; @todo: needs a weak implementation +extern ASM_PFX(SecCarInit) + +; +; Define the data length that we saved on the stack top +; +DATA_LEN_OF_PER0 EQU 18h +DATA_LEN_OF_MCUD EQU 18h +DATA_LEN_AT_STACK_TOP EQU (DATA_LEN_OF_PER0 + DATA_LEN_OF_MCUD + 4) + +; +; @todo: These structures are moved from MicrocodeLoadNasm.inc to avoid +; build error. This needs to be fixed later on. +; +struc MicrocodeHdr + .MicrocodeHdrVersion: resd 1 + .MicrocodeHdrRevision: resd 1 + .MicrocodeHdrDate: resd 1 + .MicrocodeHdrProcessor: resd 1 + .MicrocodeHdrChecksum: resd 1 + .MicrocodeHdrLoader: resd 1 + .MicrocodeHdrFlags: resd 1 + .MicrocodeHdrDataSize: resd 1 + .MicrocodeHdrTotalSize: resd 1 + .MicrocodeHdrRsvd: resd 3 + .size: +endstruc + +struc ExtSigHdr + .ExtSigHdrCount: resd 1 + .ExtSigHdrChecksum: resd 1 + .ExtSigHdrRsvd: resd 3 + .size: +endstruc + +struc ExtSig + .ExtSigProcessor: resd 1 + .ExtSigFlags: resd 1 + .ExtSigChecksum: resd 1 + .size: +endstruc + +struc LoadMicrocodeParamsFsp24 + ; FSP_UPD_HEADER { + .FspUpdHeaderSignature: resd 2 + .FspUpdHeaderRevision: resb 1 + .FspUpdHeaderReserved: resb 23 + ; } + ; FSPT_ARCH2_UPD { + .FsptArchRevision: resb 1 + .FsptArchReserved: resb 3 + .FsptArchLength: resd 1 + .FspDebugHandler resq 1 + .FsptArchUpd: resd 4 + ; } + ; FSPT_CORE_UPD { + .MicrocodeCodeAddr: resq 1 + .MicrocodeCodeSize: resq 1 + .CodeRegionBase: resq 1 + .CodeRegionSize: resq 1 + ; } + .size: +endstruc + +; +; @todo: The strong/weak implementation does not work. +; This needs to be reviewed later. +; +;-------------------------------------------------------------------------= ----- +; +;;global ASM_PFX(SecPlatformInitDefault) +;ASM_PFX(SecPlatformInitDefault): +; ; Inputs: +; ; ymm7 -> Return address +; ; Outputs: +; ; rax -> 0 - Successful, Non-zero - Failed. +; ; Register Usage: +; ; rax is cleared and rbp is used for return address. +; ; All others reserved. +; +; ; Save return address to RBP +; LOAD_RBP +; +; xor rax, rax +;Exit1: +; jmp rbp + +;-------------------------------------------------------------------------= ----- +global ASM_PFX(LoadMicrocodeDefault) +ASM_PFX(LoadMicrocodeDefault): + ; Inputs: + ; rsp -> LoadMicrocodeParams pointer + ; Register Usage: + ; rsp Preserved + ; All others destroyed + ; Assumptions: + ; No memory available, stack is hard-coded and used for return address + ; Executed by SBSP and NBSP + ; Beginning of microcode update region starts on paragraph boundary + + ; + ; Save return address to RBP + ; + LOAD_RBP + + cmp rsp, 0 + jz ParamError + mov eax, dword [rsp + 8] ; Parameter pointer + cmp eax, 0 + jz ParamError + mov esp, eax + + ; skip loading Microcode if the MicrocodeCodeSize is zero + ; and report error if size is less than 2k + ; first check UPD header revision + cmp byte [rsp + LoadMicrocodeParamsFsp24.FspUpdHeaderRevision], 2 + jb ParamError + cmp byte [rsp + LoadMicrocodeParamsFsp24.FsptArchRevision], 2 + jne ParamError + + ; UPD structure is compliant with FSP spec 2.4 + mov eax, dword [rsp + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] + cmp eax, 0 + jz Exit2 + cmp eax, 0800h + jl ParamError + + mov esi, dword [rsp + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] + cmp esi, 0 + jnz CheckMainHeader + +ParamError: + mov rax, 08000000000000002h + jmp Exit2 + +CheckMainHeader: + ; Get processor signature and platform ID from the installed processor + ; and save into registers for later use + ; ebx =3D processor signature + ; edx =3D platform ID + mov eax, 1 + cpuid + mov ebx, eax + mov ecx, MSR_IA32_PLATFORM_ID + rdmsr + mov ecx, edx + shr ecx, 50-32 ; shift (50d-32d=3D18d=3D0x12= ) bits + and ecx, 7h ; platform id at bit[52..50] + mov edx, 1 + shl edx, cl + + ; Current register usage + ; esp -> stack with parameters + ; esi -> microcode update to check + ; ebx =3D processor signature + ; edx =3D platform ID + + ; Check for valid microcode header + ; Minimal test checking for header version and loader version as 1 + mov eax, dword 1 + cmp dword [esi + MicrocodeHdr.MicrocodeHdrVersion], eax + jne AdvanceFixedSize + cmp dword [esi + MicrocodeHdr.MicrocodeHdrLoader], eax + jne AdvanceFixedSize + + ; Check if signature and plaform ID match + cmp ebx, dword [esi + MicrocodeHdr.MicrocodeHdrProcessor] + jne LoadMicrocodeDefault1 + test edx, dword [esi + MicrocodeHdr.MicrocodeHdrFlags ] + jnz LoadCheck ; Jif signature and platform ID match + +LoadMicrocodeDefault1: + ; Check if extended header exists + ; First check if MicrocodeHdrTotalSize and MicrocodeHdrDataSize are val= id + xor rax, rax + cmp dword [esi + MicrocodeHdr.MicrocodeHdrTotalSize], eax + je NextMicrocode + cmp dword [esi + MicrocodeHdr.MicrocodeHdrDataSize], eax + je NextMicrocode + + ; Then verify total size - sizeof header > data size + mov ecx, dword [esi + MicrocodeHdr.MicrocodeHdrTotalSize] + sub ecx, MicrocodeHdr.size + cmp ecx, dword [esi + MicrocodeHdr.MicrocodeHdrDataSize] + jng NextMicrocode ; Jif extended header does not exist + + ; Set edi -> extended header + mov edi, esi + add edi, MicrocodeHdr.size + add edi, dword [esi + MicrocodeHdr.MicrocodeHdrDataSize] + + ; Get count of extended structures + mov ecx, dword [edi + ExtSigHdr.ExtSigHdrCount] + + ; Move pointer to first signature structure + add edi, ExtSigHdr.size + +CheckExtSig: + ; Check if extended signature and platform ID match + cmp dword [edi + ExtSig.ExtSigProcessor], ebx + jne LoadMicrocodeDefault2 + test dword [edi + ExtSig.ExtSigFlags], edx + jnz LoadCheck ; Jif signature and platform ID match +LoadMicrocodeDefault2: + ; Check if any more extended signatures exist + add edi, ExtSig.size + loop CheckExtSig + +NextMicrocode: + ; Advance just after end of this microcode + xor rax, rax + cmp dword [esi + MicrocodeHdr.MicrocodeHdrTotalSize], eax + je LoadMicrocodeDefault3 + add esi, dword [esi + MicrocodeHdr.MicrocodeHdrTotalSize] + jmp CheckAddress +LoadMicrocodeDefault3: + add esi, dword 2048 + jmp CheckAddress + +AdvanceFixedSize: + ; Advance by 4X dwords + add esi, dword 1024 + +CheckAddress: + ; Check UPD header revision + cmp byte [rsp + LoadMicrocodeParamsFsp24.FspUpdHeaderRevision], 2 + jb ParamError + cmp byte [rsp + LoadMicrocodeParamsFsp24.FsptArchRevision], 2 + jne ParamError + + ; UPD structure is compliant with FSP spec 2.4 + ; Is automatic size detection ? + mov rax, qword [rsp + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] + cmp rax, 0ffffffffffffffffh + jz LoadMicrocodeDefault4 + + ; Address >=3D microcode region address + microcode region size? + add rax, qword [rsp + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] + cmp rsi, rax + jae Done ;Jif address is outside of microcode region + jmp CheckMainHeader + +LoadMicrocodeDefault4: + ; Is valid Microcode start point ? + cmp dword [esi + MicrocodeHdr.MicrocodeHdrVersion], 0ffffffffh + jz Done + +LoadCheck: + ; Get the revision of the current microcode update loaded + mov ecx, MSR_IA32_BIOS_SIGN_ID + xor eax, eax ; Clear EAX + xor edx, edx ; Clear EDX + wrmsr ; Load 0 to MSR at 8Bh + + mov eax, 1 + cpuid + mov ecx, MSR_IA32_BIOS_SIGN_ID + rdmsr ; Get current microcode signature + + ; Verify this microcode update is not already loaded + cmp dword [esi + MicrocodeHdr.MicrocodeHdrRevision], edx + je Continue + +LoadMicrocode: + ; EAX contains the linear address of the start of the Update Data + ; EDX contains zero + ; ECX contains 79h (IA32_BIOS_UPDT_TRIG) + ; Start microcode load with wrmsr + mov eax, esi + add eax, MicrocodeHdr.size + xor edx, edx + mov ecx, MSR_IA32_BIOS_UPDT_TRIG + wrmsr + mov eax, 1 + cpuid + +Continue: + jmp NextMicrocode + +Done: + mov eax, 1 + cpuid + mov ecx, MSR_IA32_BIOS_SIGN_ID + rdmsr ; Get current microcode signature + xor eax, eax + cmp edx, 0 + jnz Exit2 + mov eax, 0800000000000000Eh + +Exit2: + jmp rbp + + +global ASM_PFX(EstablishStackFsp) +ASM_PFX(EstablishStackFsp): + ; + ; Save parameter pointer in rdx + ; + mov rdx, qword [rsp + 8] + + ; + ; Enable FSP STACK + ; + mov rax, ASM_PFX(PcdGet32 (PcdTemporaryRamBase)) + mov esp, DWORD[rax] + mov rax, ASM_PFX(PcdGet32 (PcdTemporaryRamSize)) + add esp, DWORD[rax] + + sub esp, 4 + mov dword[esp], DATA_LEN_OF_MCUD ; Size of the data region + sub esp, 4 + mov dword[esp], 4455434Dh ; Signature of the data region '= MCUD' + + ; check UPD structure revision (rdx + 8) + cmp byte [rdx + LoadMicrocodeParamsFsp24.FspUpdHeaderRevision], 2 + jb ParamError1 + cmp byte [rdx + LoadMicrocodeParamsFsp24.FsptArchRevision], 2 + je Fsp24UpdHeader + +ParamError1: + mov rax, 08000000000000002h + jmp EstablishStackFspExit + +Fsp24UpdHeader: + ; UPD structure is compliant with FSP spec 2.4 + xor rax, rax + mov rax, qword [rdx + LoadMicrocodeParamsFsp24.CodeRegionSize] = ; Code size sizeof(FSPT_UPD_COMMON) + 18h + sub rsp, 8 + mov qword[rsp], rax + mov rax, qword [rdx + LoadMicrocodeParamsFsp24.CodeRegionBase] = ; Code base sizeof(FSPT_UPD_COMMON) + 10h + sub rsp, 8 + mov qword[rsp], rax + mov rax, qword [rdx + LoadMicrocodeParamsFsp24.MicrocodeCodeSize] = ; Microcode size sizeof(FSPT_UPD_COMMON) + 8h + sub rsp, 8 + mov qword[rsp], rax + mov rax, qword [rdx + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr] = ; Microcode base sizeof(FSPT_UPD_COMMON) + 0h + sub rsp, 8 + mov qword[rsp], rax + +ContinueAfterUpdPush: + ; + ; Save API entry/exit timestamp into stack + ; + sub esp, 4 + mov dword[esp], DATA_LEN_OF_PER0 ; Size of the data region + sub esp, 4 + mov dword[esp], 30524550h ; Signature of the data region '= PER0' + rdtsc + sub esp, 4 + mov dword[esp], edx + sub esp, 4 + mov dword[esp], eax + LOAD_TS rax + push rax + + ; + ; Terminator for the data on stack + ; + push 0 + + ; + ; Set ECX/EDX to the BootLoader temporary memory range + ; + mov rcx, ASM_PFX(PcdGet32 (PcdTemporaryRamBase)) + mov edx, [ecx] + mov rcx, ASM_PFX(PcdGet32 (PcdTemporaryRamSize)) + add edx, [ecx] + mov rcx, ASM_PFX(PcdGet32 (PcdFspReservedBufferSize)) + sub edx, [ecx] + mov rcx, ASM_PFX(PcdGet32 (PcdTemporaryRamBase)) + mov ecx, [ecx] + + cmp ecx, edx ; If PcdFspReservedBufferSize >=3D Pc= dTemporaryRamSize, then error. + jb EstablishStackFspSuccess + mov rax, 08000000000000003h ; EFI_UNSUPPORTED + jmp EstablishStackFspExit +EstablishStackFspSuccess: + xor rax, rax + +EstablishStackFspExit: + RET_YMM + +;-------------------------------------------------------------------------= --- +; TempRamInit API +; +; This FSP API will load the microcode update, enable code caching for the +; region specified by the boot loader and also setup a temporary stack to = be +; used till main memory is initialized. +; +;-------------------------------------------------------------------------= --- +global ASM_PFX(TempRamInitApi) +ASM_PFX(TempRamInitApi): + ; + ; Ensure both SSE and AVX are enabled + ; + ENABLE_SSE + ENABLE_AVX + + ; + ; Save RBP, RBX, RSI, RDI and RSP in YMM7, YMM8 and YMM6 + ; + SAVE_REGS + + ; + ; Save BFV address in YMM9 + ; + SAVE_BFV rbp + + ; + ; Save timestamp into YMM6 + ; + rdtsc + shl rdx, 32 + or rax, rdx + SAVE_TS rax + + ; + ; Check Parameter + ; + mov rax, qword [rsp + 8] + cmp rax, 0 + mov rax, 08000000000000002h + jz TempRamInitExit + + ; + ; Sec Platform Init + ; + CALL_YMM ASM_PFX(SecPlatformInit) + cmp eax, 0 + jnz TempRamInitExit + + ; Load microcode + LOAD_RSP + CALL_YMM ASM_PFX(LoadMicrocodeDefault) + SAVE_UCODE_STATUS rax ; Save microcode return status in SLOT= 0 in YMM9 (upper 128bits). + ; @note If return value rax is not 0, microcode did not load, but contin= ue and attempt to boot. + + ; Call Sec CAR Init + LOAD_RSP + CALL_YMM ASM_PFX(SecCarInit) + cmp rax, 0 + jnz TempRamInitExit + + LOAD_RSP + CALL_YMM ASM_PFX(EstablishStackFsp) + cmp rax, 0 + jnz TempRamInitExit + + LOAD_UCODE_STATUS rax ; Restore microcode status if no CAR i= nit error from SLOT 0 in YMM9 (upper 128bits). + +TempRamInitExit: + mov bl, al ; save al data in bl + mov al, 07Fh ; API exit postcode 7f + out 080h, al + mov al, bl ; restore al data from bl + + ; + ; Load RBP, RBX, RSI, RDI and RSP from YMM7, YMM8 and YMM6 + ; + LOAD_REGS + LOAD_BFV rbp + ret + +;-------------------------------------------------------------------------= --- +; Module Entrypoint API +;-------------------------------------------------------------------------= --- +global ASM_PFX(_ModuleEntryPoint) +ASM_PFX(_ModuleEntryPoint): + jmp $ + diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm b/IntelFsp2Pkg/FspS= ecCore/X64/FspHelper.nasm new file mode 100644 index 0000000000..122fa1d174 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm @@ -0,0 +1,34 @@ +;; @file +; Provide FSP helper function. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + DEFAULT REL + SECTION .text + +global ASM_PFX(AsmGetFspBaseAddress) +ASM_PFX(AsmGetFspBaseAddress): + call ASM_PFX(AsmGetFspInfoHeader) + add rax, 0x1C + mov eax, [rax] + ret + +global ASM_PFX(AsmGetFspInfoHeader) +ASM_PFX(AsmGetFspInfoHeader): + lea rax, [ASM_PFX(AsmGetFspInfoHeader)] + DB 0x48, 0x2d ; sub rax, 0x???????? +global ASM_PFX(FspInfoHeaderRelativeOff) +ASM_PFX(FspInfoHeaderRelativeOff): + DD 0x12345678 ; This value must be patched by the buil= d script + and rax, 0xffffffff + ret + +global ASM_PFX(AsmGetFspInfoHeaderNoStack) +ASM_PFX(AsmGetFspInfoHeaderNoStack): + lea rax, [ASM_PFX(AsmGetFspInfoHeader)] + lea rcx, [ASM_PFX(FspInfoHeaderRelativeOff)] + mov ecx, [rcx] + sub rax, rcx + and rax, 0xffffffff + jmp rdi diff --git a/IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc b/IntelFsp2P= kg/FspSecCore/X64/MicrocodeLoadNasm.inc new file mode 100644 index 0000000000..4ec5070d25 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc @@ -0,0 +1,11 @@ +;; @file +; +;@copyright +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + +MSR_IA32_PLATFORM_ID equ 000000017h +MSR_IA32_BIOS_UPDT_TRIG equ 000000079h +MSR_IA32_BIOS_SIGN_ID equ 00000008bh + diff --git a/IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm b/IntelFsp2Pkg/FspSec= Core/X64/ReadRsp.nasm new file mode 100644 index 0000000000..af82509803 --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm @@ -0,0 +1,22 @@ +;; @file +; Provide read RSP function +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; +;-------------------------------------------------------------------------= ----- + + SECTION .text + +;-------------------------------------------------------------------------= ----- +; UINTN +; EFIAPI +; AsmReadStackPointer ( +; VOID +; ); +;-------------------------------------------------------------------------= ----- +global ASM_PFX(AsmReadStackPointer) +ASM_PFX(AsmReadStackPointer): + mov rax, rsp + ret + diff --git a/IntelFsp2Pkg/FspSecCore/X64/Stack.nasm b/IntelFsp2Pkg/FspSecCo= re/X64/Stack.nasm new file mode 100644 index 0000000000..0af7f54f6f --- /dev/null +++ b/IntelFsp2Pkg/FspSecCore/X64/Stack.nasm @@ -0,0 +1,73 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Abstract: +; +; Switch the stack from temporary memory to permanent memory. +; +;-------------------------------------------------------------------------= ----- + + SECTION .text + +;-------------------------------------------------------------------------= ----- +; VOID +; EFIAPI +; SecSwitchStack ( +; UINT64 TemporaryMemoryBase, +; UINT64 PermanentMemoryBase +; ); +;-------------------------------------------------------------------------= ----- +global ASM_PFX(SecSwitchStack) +ASM_PFX(SecSwitchStack): + ; + ; Save four register: rax, rbx, rcx, rdx + ; + push rax + push rbx + push rcx + push rdx + + ; + ; !!CAUTION!! this function address's is pushed into stack after + ; migration of whole temporary memory, so need save it to permanent + ; memory at first! + ; + + mov rbx, rcx ; Save the first parameter + mov rcx, rdx ; Save the second parameter + + ; + ; Save this function's return address into permanent memory at first. + ; Then, Fixup the esp point to permanent memory + ; + mov rax, rsp + sub rax, rbx + add rax, rcx + mov rdx, qword [rsp] ; copy pushed register's value to perma= nent memory + mov qword [rax], rdx + mov rdx, qword [rsp + 8] + mov qword [rax + 8], rdx + mov rdx, qword [rsp + 16] + mov qword [rax + 16], rdx + mov rdx, qword [rsp + 24] + mov qword [rax + 24], rdx + mov rdx, qword [rsp + 32] ; Update this function's return address= into permanent memory + mov qword [rax + 32], rdx + mov rsp, rax ; From now, rsp is pointed to permanent= memory + + ; + ; Fixup the rbp point to permanent memory + ; + mov rax, rbp + sub rax, rbx + add rax, rcx + mov rbp, rax ; From now, rbp is pointed to permanent= memory + + pop rdx + pop rcx + pop rbx + pop rax + ret + diff --git a/IntelFsp2Pkg/Include/Guid/FspHeaderFile.h b/IntelFsp2Pkg/Inclu= de/Guid/FspHeaderFile.h index e5a9d7a2b4..c660defac3 100644 --- a/IntelFsp2Pkg/Include/Guid/FspHeaderFile.h +++ b/IntelFsp2Pkg/Include/Guid/FspHeaderFile.h @@ -2,11 +2,13 @@ Intel FSP Header File definition from Intel Firmware Support Package Ext= ernal Architecture Specification v2.0 and above. =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include + #ifndef __FSP_HEADER_FILE_H__ #define __FSP_HEADER_FILE_H__ =20 @@ -24,6 +26,12 @@ =20 #define FSP_INFO_HEADER_SIGNATURE SIGNATURE_32 ('F', 'S', 'P', 'H') =20 +#define IMAGE_ATTRIBUTE_GRAPHICS_SUPPORT BIT0 +#define IMAGE_ATTRIBUTE_DISPATCH_MODE_SUPPORT BIT1 +#define IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT BIT2 +#define FSP_IA32 0 +#define FSP_X64 1 + #pragma pack(1) =20 /// @@ -49,7 +57,7 @@ typedef struct { UINT8 SpecVersion; /// /// Byte 0x0B: Revision of the FSP Information Header. - /// The Current value for this field is 0x6. + /// The Current value for this field is 0x7. /// UINT8 HeaderRevision; /// @@ -82,6 +90,10 @@ typedef struct { UINT32 ImageBase; /// /// Byte 0x20: Attribute for the FSP binary. + /// Bit 0: Graphics Support - Set to 1 when FSP supports enabling Grap= hics Display. + /// Bit 1: Dispatch Mode Support - Set to 1 when FSP supports the opti= onal Dispatch Mode API defined in Section 7.2 and 9. This bit is only valid= if FSP HeaderRevision is >=3D 4. + /// Bit 2: 64-bit mode support - Set to 1 to indicate FSP supports 64-= bit long mode interfaces. Set to 0 to indicate FSP supports 32-bit mode int= erfaces. This bit is only valid if FSP HeaderRevision is >=3D 7. + /// Bits 15:3 - Reserved /// UINT16 ImageAttribute; /// diff --git a/IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc b/IntelFsp2Pkg/= Include/SaveRestoreSseAvxNasm.inc new file mode 100644 index 0000000000..e8bd91669d --- /dev/null +++ b/IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc @@ -0,0 +1,284 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Abstract: +; +; Provide macro for register save/restore using SSE registers +; +;-------------------------------------------------------------------------= ----- + +; +; Define SSE and AVX instruction set +; +; +; Define SSE macros using SSE 4.1 instructions +; args 1:XMM, 2:IDX, 3:REG +; +%macro SXMMN 3 + pinsrq %1, %3, (%2 & 3) + %endmacro + +; +; args 1:XMM, 2:REG, 3:IDX +; +%macro LXMMN 3 + pextrq %2, %1, (%3 & 3) + %endmacro + +; +; Define AVX macros using AVX instructions +; Save XMM to YMM +; args 1:YMM, 2:IDX (0 - lower 128bits, 1 - upper 128bits), 3:XMM +; +%macro SYMMN 3 + vinsertf128 %1, %1, %3, %2 + %endmacro + +; +; Restore XMM from YMM +; args 1:YMM, 2:XMM, 3:IDX (0 - lower 128bits, 1 - upper 128bits) +; +%macro LYMMN 3 + vextractf128 %2, %1, %3 + %endmacro + +; +; Upper half of YMM7 to save RBP and RBX. Upper half of YMM8 to save RSI a= nd RDI. +; Modified: XMM5, YMM6, YMM7 and YMM8 +; +%macro SAVE_REGS 0 + SXMMN xmm5, 0, rbp + SXMMN xmm5, 1, rbx + SYMMN ymm7, 1, xmm5 + SXMMN xmm5, 0, rsi + SXMMN xmm5, 1, rdi + SYMMN ymm8, 1, xmm5 + SAVE_RSP + %endmacro + +; +; Upper half of YMM7 to restore RBP and RBX. Upper half of YMM8 to restore= RSI and RDI. +; Modified: XMM5, RBP, RBX, RSI, RDI and RSP +; +%macro LOAD_REGS 0 + LYMMN ymm7, xmm5, 1 + LXMMN xmm5, rbp, 0 + LXMMN xmm5, rbx, 1 + LYMMN ymm8, xmm5, 1 + LXMMN xmm5, rsi, 0 + LXMMN xmm5, rdi, 1 + LOAD_RSP + %endmacro +; +; Restore RBP from YMM7[128:191] +; Modified: XMM5 and RBP +; +%macro LOAD_RBP 0 + LYMMN ymm7, xmm5, 1 + movq rbp, xmm5 + %endmacro + +; +; Restore RBX from YMM7[192:255] +; Modified: XMM5 and RBX +; +%macro LOAD_RBX 0 + LYMMN ymm7, xmm5, 1 + LXMMN xmm5, rbx, 1 + %endmacro + +; +; Upper half of YMM6 to save/restore Time Stamp, RSP +; +; +; Save Time Stamp to YMM6[192:255] +; arg 1:general purpose register which holds time stamp +; Modified: XMM5 and YMM6 +; +%macro SAVE_TS 1 + LYMMN ymm6, xmm5, 1 + SXMMN xmm5, 1, %1 + SYMMN ymm6, 1, xmm5 + %endmacro + +; +; Restore Time Stamp from YMM6[192:255] +; arg 1:general purpose register where to save time stamp +; Modified: XMM5 and %1 +; +%macro LOAD_TS 1 + LYMMN ymm6, xmm5, 1 + LXMMN xmm5, %1, 1 + %endmacro + +; +; Save RSP to YMM6[128:191] +; Modified: XMM5 and YMM6 +; +%macro SAVE_RSP 0 + LYMMN ymm6, xmm5, 1 + SXMMN xmm5, 0, rsp + SYMMN ymm6, 1, xmm5 + %endmacro + +; +; Restore RSP from YMM6[128:191] +; Modified: XMM5 and RSP +; +%macro LOAD_RSP 0 + LYMMN ymm6, xmm5, 1 + movq rsp, xmm5 + %endmacro + +; +; Upper half of YMM9 to save/restore UCODE status, BFV address +; +; +; Save uCode status to YMM9[192:255] +; arg 1:general purpose register which holds uCode status +; Modified: XMM5 and YMM9 +; +%macro SAVE_UCODE_STATUS 1 + LYMMN ymm9, xmm5, 1 + SXMMN xmm5, 0, %1 + SYMMN ymm9, 1, xmm5 + %endmacro + +; +; Restore uCode status from YMM9[192:255] +; arg 1:general purpose register where to save uCode status +; Modified: XMM5 and %1 +; +%macro LOAD_UCODE_STATUS 1 + LYMMN ymm9, xmm5, 1 + movq %1, xmm5 + %endmacro + +; +; Save BFV address to YMM9[128:191] +; arg 1:general purpose register which holds BFV address +; Modified: XMM5 and YMM9 +; +%macro SAVE_BFV 1 + LYMMN ymm9, xmm5, 1 + SXMMN xmm5, 1, %1 + SYMMN ymm9, 1, xmm5 + %endmacro + +; +; Restore BFV address from YMM9[128:191] +; arg 1:general purpose register where to save BFV address +; Modified: XMM5 and %1 +; +%macro LOAD_BFV 1 + LYMMN ymm9, xmm5, 1 + LXMMN xmm5, %1, 1 + %endmacro + +; +; YMM7[128:191] for calling stack +; arg 1:Entry +; Modified: RSI, XMM5, YMM7 +; +%macro CALL_YMM 1 + mov rsi, %%ReturnAddress + LYMMN ymm7, xmm5, 1 + SXMMN xmm5, 0, rsi + SYMMN ymm7, 1, xmm5 + mov rsi, %1 + jmp rsi +%%ReturnAddress: + %endmacro +; +; Restore RIP from YMM7[128:191] +; Modified: RSI, XMM5 +; +%macro RET_YMM 0 + LYMMN ymm7, xmm5, 1 + movq rsi, xmm5 + jmp rsi + %endmacro + +%macro ENABLE_SSE 0 + ; + ; Initialize floating point units + ; + jmp NextAddress +align 4 + ; + ; Float control word initial value: + ; all exceptions masked, double-precision, round-to-nearest + ; +FpuControlWord DW 027Fh + ; + ; Multimedia-extensions control word: + ; all exceptions masked, round-to-nearest, flush to zero for m= asked underflow + ; +MmxControlWord DQ 01F80h +SseError: + ; + ; Processor has to support SSE + ; + jmp SseError +NextAddress: + finit + mov rax, FpuControlWord + fldcw [rax] + + ; + ; Use CpuId instruction (CPUID.01H:EDX.SSE[bit 25] =3D 1) to t= est + ; whether the processor supports SSE instruction. + ; + mov rax, 1 + cpuid + bt rdx, 25 + jnc SseError + + ; + ; SSE 4.1 support + ; + bt ecx, 19 + jnc SseError + + ; + ; Set OSFXSR bit (bit #9) & OSXMMEXCPT bit (bit #10) + ; + mov rax, cr4 + or rax, 00000600h + mov cr4, rax + + ; + ; The processor should support SSE instruction and we can use + ; ldmxcsr instruction + ; + mov rax, MmxControlWord + ldmxcsr [rax] + %endmacro + +%macro ENABLE_AVX 0 + mov eax, 1 + cpuid + and ecx, 10000000h + cmp ecx, 10000000h ; check AVX feature flag + je EnableAvx +AvxError: + ; + ; Processor has to support AVX + ; + jmp AvxError +EnableAvx: + ; + ; Set OSXSAVE bit (bit #18) to enable xgetbv/xsetbv instruction + ; + mov rax, cr4 + or rax, 00040000h + mov cr4, rax + + mov rcx, 0 ; index 0 + xgetbv ; result in edx:eax + or eax, 00000006h ; Set XCR0 bit #1 and bit #2 to enable = SSE state and AVX state + xsetbv + %endmacro + diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c b/IntelFs= p2Pkg/Library/BaseFspCommonLib/FspCommonLib.c index cd10b63c95..67e08a9e7e 100644 --- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c +++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -38,7 +38,8 @@ typedef struct { } CONTEXT_STACK; =20 // -// API return address +0xB0 +// API return address +0xB8 +// Reserved +0xB0 // push API Parameter2 +0xA8 // push API Parameter1 +0xA0 // push FspInfoHeader +0x98 @@ -54,6 +55,7 @@ typedef struct { UINT32 Flags[2]; UINT64 FspInfoHeader; UINT64 ApiParam[2]; + UINT64 Reserved; // The reserved QWORD is needed for stack alig= nment in X64. UINT64 ApiRet; // 64bit stack format is different from the 32= bit one due to x64 calling convention } CONTEXT_STACK_64; =20 diff --git a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm b/In= telFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm index bd36fe4b8b..1ea1220608 100644 --- a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm +++ b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm @@ -47,7 +47,8 @@ ASM_PFX(Loader2PeiSwitchStack): ;-------------------------------------------------------------------------= ----- global ASM_PFX(FspSwitchStack) ASM_PFX(FspSwitchStack): - ; Save current contexts + ; Save current contexts. The format must align with CONTEXT_STACK_64. + push rdx ; Reserved QWORD for stack alignment push rdx ; ApiParam2 push rcx ; ApiParam1 push rax ; FspInfoHeader @@ -67,6 +68,6 @@ ASM_PFX(FspSwitchStack): add rsp, 16 POPA_64 popfq - add rsp, 24 ; FspInfoHeader + ApiParam[2] + add rsp, 32 ; FspInfoHeader + ApiParam[2] + Reserved QWORD ret =20 --=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 (#88931): https://edk2.groups.io/g/devel/message/88931 Mute This Topic: https://groups.io/mt/90482850/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 Wed May 15 03:39:09 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+88933+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+88933+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011882; cv=none; d=zohomail.com; s=zohoarc; b=O9vmqVUo5j+hrLzHGAgBbbBLzyFsIKDXEI4P0wu4FFyhDzA0hgQdjCYORQLx/MtgCDwK5y7UiKPgJJ8GqONVjMCwJPZzcYfP762VxkdUIYqZlaAiYKr42/1OeT4fM/qYXlA2y63S2oKkeyEtG6YG02uSAdZbHEZdond4KFh2Dd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011882; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=wOKo/f9WgEBTyhvwh05bQ/I3FxrsbT/vfloLTrflC00=; b=jgutCgyCI7qymuTmFb07PcwJ+ZmEYwdJNy6FkGiD6UZDx6mFjSqTMlrPEsCZ8MvZg4eEqrGtARKkCMqBfEK83bhfDoB7zsigPD4cdDXK8K8QB/Uis/nZWl9z1WGosKSW+dG6V3ER5KgT1gZLMYCG1A16/yCt7/tN5rlHrXgEACg= 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+88933+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 1650011881998210.08797812666785; Fri, 15 Apr 2022 01:38:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EZyqYY1788612xzi5bgOfRLL; Fri, 15 Apr 2022 01:38:01 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5019.1650011880994981369 for ; Fri, 15 Apr 2022 01:38:01 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563821" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563821" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:00 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990474" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:37:59 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 5/8] IntelFsp2Pkg: SecFspSecPlatformLibNull support for X64 Date: Fri, 15 Apr 2022 16:37:40 +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: nOg4aWVwjonM329mWA0oJ9MUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011881; bh=T962LDS1BV2MLTdooQmUyaDOdI8zFcqQOyaBzE1p1i0=; h=Cc:Date:From:Reply-To:Subject:To; b=UQITt5AarL4/a/TtgCfHqtjTLYLum20BDeWU/LRuhStEczPsy8JR2f+tMzS0VHo9/QC M1XXPfjbImzDSqgB2GRKRTnxKywUgad9DP8/N4FX6OQeS+/n4HqP9KBPqxq6AbytS1aWr TMXHl1KBEVyfUnFvB7ogJYacumvS9rPh+jU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011882317100014 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 SecFspSecPlatformLibNull support for X64. 2.Added X64 support to IntelFsp2Pkg.dsc. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- IntelFsp2Pkg/IntelFsp2Pkg.dsc | 4 +-- .../SecFspSecPlatformLibNull.inf | 8 +++-- .../SecFspSecPlatformLibNull/X64/Long64.nasm | 31 +++++++++++++++++ .../SecFspSecPlatformLibNull/X64/SecCarInit.nasm | 40 ++++++++++++++++++= ++++ 4 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long6= 4.nasm create mode 100644 IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCa= rInit.nasm diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc index c1414f7e75..7cf7e88245 100644 --- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc @@ -1,7 +1,7 @@ ## @file # Provides driver and definitions to build fsp. # -# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -12,7 +12,7 @@ PLATFORM_VERSION =3D 0.1 DSC_SPECIFICATION =3D 0x00010005 OUTPUT_DIRECTORY =3D Build/IntelFsp2Pkg - SUPPORTED_ARCHITECTURES =3D IA32 + SUPPORTED_ARCHITECTURES =3D IA32|X64 BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT SKUID_IDENTIFIER =3D DEFAULT =20 diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatfor= mLibNull.inf b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatf= ormLibNull.inf index 42e7d83c32..55ee1b98a2 100644 --- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNul= l.inf +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNul= l.inf @@ -1,7 +1,7 @@ ## @file # NULL instance of Platform Sec Lib. # -# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -23,7 +23,7 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 ##########################################################################= ###### @@ -39,6 +39,10 @@ Ia32/Flat32.nasm Ia32/SecCarInit.nasm =20 +[Sources.X64] + X64/Long64.nasm + X64/SecCarInit.nasm + ##########################################################################= ###### # # Package Dependency Section - list of Package files that are required for diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm = b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm new file mode 100644 index 0000000000..836257f962 --- /dev/null +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm @@ -0,0 +1,31 @@ +;; @file +; This is the code that performs early platform initialization. +; It consumes the reset vector, configures the stack. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + +; +; Define assembler characteristics +; + +extern ASM_PFX(TempRamInitApi) + +SECTION .text + +%macro RET_RSI 0 + + movd rsi, mm7 ; restore RSI from MM7 + jmp rsi + +%endmacro + +; +; Perform early platform initialization +; +global ASM_PFX(SecPlatformInit) +ASM_PFX(SecPlatformInit): + + RET_RSI + diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.n= asm b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm new file mode 100644 index 0000000000..e64c77ed18 --- /dev/null +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm @@ -0,0 +1,40 @@ +;; @file +; SEC CAR function +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +;; + +; +; Define assembler characteristics +; + +%macro RET_RSI 0 + + movd rsi, mm7 ; move ReturnAddress from MM7 to R= SI + jmp rsi + +%endmacro + +SECTION .text + +;-------------------------------------------------------------------------= ---- +; +; Section: SecCarInit +; +; Description: This function initializes the Cache for Data, Stack, and C= ode +; +;-------------------------------------------------------------------------= ---- +global ASM_PFX(SecCarInit) +ASM_PFX(SecCarInit): + + ; + ; Set up CAR + ; + + xor rax, rax + +SecCarInitExit: + + RET_RSI + --=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 (#88933): https://edk2.groups.io/g/devel/message/88933 Mute This Topic: https://groups.io/mt/90482852/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 Wed May 15 03:39:09 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+88934+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+88934+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011883; cv=none; d=zohomail.com; s=zohoarc; b=lu2Cr4sUHIhs4FtFHnCY3ydM07okJDDFY3Th5DER+w6wg1fRmLJszQCe2UVJbebZVf00fT0WrqiCx4e5ykikzFER6BkkDtT93B6G4z/evBsSZBPeK9CwHwCWcx05l+VUYmTAIlqVPbaj9KqpAlC5RwsoThWHqwMNnlCacXzGglI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011883; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=IMp8bTQVSG1xgTZvwhiwkSpxBYBxW41MOFBuAnJ7o3U=; b=MkxGNL0Ezce8Us3OaJlHe4C7w6Arqk4xC7YQTfk8LAHJOZm9NDqjDrVkwnP3MH7cDsa67ZwABjQ5sQFemo/D9DtHgtX3iCaqV1SZq/JkiJ1xpzPuZ5fZLPmq8C9heqHqJhSfKlxYmZwBIeqxIt5LbpTIOtOkItV32Al4+Jkyspc= 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+88934+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 1650011883552666.09128049756; Fri, 15 Apr 2022 01:38:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9V0KYY1788612xGmBakpNnyO; Fri, 15 Apr 2022 01:38:03 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5019.1650011880994981369 for ; Fri, 15 Apr 2022 01:38:02 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563833" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563833" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:02 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990481" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:00 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 6/8] IntelFsp2WrapperPkg: Adopt FSPM_UPD_COMMON_FSP24 for X64 Date: Fri, 15 Apr 2022 16:37:41 +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: RVugsg48n6yRwSq0bFsUm0lux1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011883; bh=ZAFi+a3xjo4R6a6ni7spXka810KoXmRkX+SJgH4UUFE=; h=Cc:Date:From:Reply-To:Subject:To; b=o2lcc2BYaeTm4m4rpLLUJO3KNfZv1e9ryJLWYOHV8/FVuewUD3Qaevk3PTw906wSsD2 cnzI+FHzBUwNbyDUl+PSaYwprXJrnO5aCrxqg1AOT3bBpw+WEO+oMmLZLqSKkRLxEQXOc K1ZHdn/LccH6GJeqnSyqFhysTmP7RZU1E4M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011884352100027 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 Adopt FSPM_UPD_COMMON_FSP24 in FspmWrapperPeim to support X64. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- .../FspmWrapperPeim/FspmWrapperPeim.c | 27 ++++++++++++++----= ---- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelF= sp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c index b0c6b2f8a6..047c2965a3 100644 --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c @@ -3,7 +3,7 @@ register TemporaryRamDonePpi to call TempRamExit API, and register Memor= yDiscoveredPpi notify to call FspSiliconInit API. =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -71,7 +71,7 @@ PeiFspMemoryInit ( UINT64 TimeStampCounterStart; VOID *FspHobListPtr; VOID *HobData; - FSPM_UPD_COMMON *FspmUpdDataPtr; + VOID *FspmUpdDataPtr; UINTN *SourceData; =20 DEBUG ((DEBUG_INFO, "PeiFspMemoryInit enter\n")); @@ -89,7 +89,7 @@ PeiFspMemoryInit ( // // Copy default FSP-M UPD data from Flash // - FspmUpdDataPtr =3D (FSPM_UPD_COMMON *)AllocateZeroPool ((UINTN)FspmHea= derPtr->CfgRegionSize); + FspmUpdDataPtr =3D AllocateZeroPool ((UINTN)FspmHeaderPtr->CfgRegionSi= ze); ASSERT (FspmUpdDataPtr !=3D NULL); SourceData =3D (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + (UINTN)Fspm= HeaderPtr->CfgRegionOffset); CopyMem (FspmUpdDataPtr, SourceData, (UINTN)FspmHeaderPtr->CfgRegionSi= ze); @@ -97,17 +97,24 @@ PeiFspMemoryInit ( // // External UPD is ready, get the buffer from PCD pointer. // - FspmUpdDataPtr =3D (FSPM_UPD_COMMON *) GetFspmUpdDataAddress(); + FspmUpdDataPtr =3D (VOID *) GetFspmUpdDataAddress(); ASSERT (FspmUpdDataPtr !=3D NULL); } =20 DEBUG ((DEBUG_INFO, "UpdateFspmUpdData enter\n")); - UpdateFspmUpdData ((VOID *)FspmUpdDataPtr); - DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspmUpdDataPtr->Fs= pmArchUpd.NvsBufferPtr)); - DEBUG ((DEBUG_INFO, " StackBase - 0x%x\n", FspmUpdDataPtr->Fs= pmArchUpd.StackBase)); - DEBUG ((DEBUG_INFO, " StackSize - 0x%x\n", FspmUpdDataPtr->Fs= pmArchUpd.StackSize)); - DEBUG ((DEBUG_INFO, " BootLoaderTolumSize - 0x%x\n", FspmUpdDataPtr->Fs= pmArchUpd.BootLoaderTolumSize)); - DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspmUpdDataPtr->Fs= pmArchUpd.BootMode)); + UpdateFspmUpdData (FspmUpdDataPtr); + if (((FSPM_UPD_COMMON *)FspmUpdDataPtr)->FspmArchUpd.Revision >=3D 3) { + DEBUG ((DEBUG_INFO, " StackBase - 0x%lx\n", ((FSPM_UPD_COMM= ON_FSP24 *)FspmUpdDataPtr)->FspmArchUpd.StackBase)); + DEBUG ((DEBUG_INFO, " StackSize - 0x%lx\n", ((FSPM_UPD_COMM= ON_FSP24 *)FspmUpdDataPtr)->FspmArchUpd.StackSize)); + DEBUG ((DEBUG_INFO, " BootLoaderTolumSize - 0x%x\n", ((FSPM_UPD_COMMO= N_FSP24 *)FspmUpdDataPtr)->FspmArchUpd.BootLoaderTolumSize)); + DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", ((FSPM_UPD_COMMO= N_FSP24 *)FspmUpdDataPtr)->FspmArchUpd.BootMode)); + } else { + DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", ((FSPM_UPD_COMMO= N *)FspmUpdDataPtr)->FspmArchUpd.NvsBufferPtr)); + DEBUG ((DEBUG_INFO, " StackBase - 0x%x\n", ((FSPM_UPD_COMMO= N *)FspmUpdDataPtr)->FspmArchUpd.StackBase)); + DEBUG ((DEBUG_INFO, " StackSize - 0x%x\n", ((FSPM_UPD_COMMO= N *)FspmUpdDataPtr)->FspmArchUpd.StackSize)); + DEBUG ((DEBUG_INFO, " BootLoaderTolumSize - 0x%x\n", ((FSPM_UPD_COMMO= N *)FspmUpdDataPtr)->FspmArchUpd.BootLoaderTolumSize)); + DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", ((FSPM_UPD_COMMO= N *)FspmUpdDataPtr)->FspmArchUpd.BootMode)); + } DEBUG ((DEBUG_INFO, " HobListPtr - 0x%x\n", &FspHobListPtr)); =20 TimeStampCounterStart =3D AsmReadTsc (); --=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 (#88934): https://edk2.groups.io/g/devel/message/88934 Mute This Topic: https://groups.io/mt/90482853/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 Wed May 15 03:39:09 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+88935+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+88935+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011886; cv=none; d=zohomail.com; s=zohoarc; b=NXq0XCN7ZEKaQ5W9wyzBM4ydxWAD0L3EHVdt/x5ptaJ8pWRbjCOgfnMniVnNf9PqJ2PbDI+f1Pj4f7uDmL6eL86dgo/XeSaeaU3MIR8KHQN4kiXITsDnEwSayJVwYZgJb8WfmUUvL9yjrEeTtUCOMIbYmkPv7WluvbKqr/snFkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011886; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Yuw98dNCGXVQxExkEcIrvpJgpA5haSYkg8dKPYBTrnw=; b=UO4I0I5j1qFZ0C58EYd3zvGWSw4yNnvk/BcgrUuuHb9NChjginilVKa/p9rzUK+1nC6cFwFEqMQUHDJqVjE1t+y36LdseMTUg7N+7qJ0+Ad01LPDj7XKDcgnmfqW5an3I1HFo5+devi+GE0/K0t8MhD+gScNa4Aal4iKEfZ7i9Q= 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+88935+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 1650011886016480.5120848440133; Fri, 15 Apr 2022 01:38:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JK4OYY1788612x5krGniyEFY; Fri, 15 Apr 2022 01:38:05 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5019.1650011880994981369 for ; Fri, 15 Apr 2022 01:38:04 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563853" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563853" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:04 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990506" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:02 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 7/8] IntelFsp2WrapperPkg: BaseFspWrapperApiLib support for X64 Date: Fri, 15 Apr 2022 16:37:42 +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: BCuui8gHBooUdwwcNoxIPJRsx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011885; bh=p+ESFpv3BO8eEZYn0iAzbsdW5VPF4fJeM86d7enPdLs=; h=Cc:Date:From:Reply-To:Subject:To; b=Gu2qyVyB5Oy1qWFUNDAMTqDfKc6XNbi4c/KvCn80EE3CeV909l4nXVn3Bm1ASpxjF67 g5NyCKa0STyZRjf3RKk/13mAsUnQkX4edi9VTh7663rJn6tiSjZonJAPjvW7KqteKdmlC LtZQ8kg2pqKsk1rHTYVSufuUigyzEls+amc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011886373100031 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 Add Execute64BitCode to execute 64bit code from long mode directly in PEI 64bit. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- .../BaseFspWrapperApiLib/FspWrapperApiLib.c | 44 +++++++++++++++++-= -- .../BaseFspWrapperApiLib/IA32/DispatchExecute.c | 23 ++++++++++- .../BaseFspWrapperApiLib/X64/DispatchExecute.c | 47 ++++++++++++++++++= ++-- 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApi= Lib.c b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c index 67faad927c..5b5beb5c65 100644 --- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c +++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c @@ -1,7 +1,7 @@ /** @file Provide FSP API related function. =20 - Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,7 +13,7 @@ #include =20 /** - Wrapper for a thunk to transition from long mode to compatibility mode = to execute 32-bit code and then transit back to + Wrapper for a thunk to transition from long mode to compatibility mode t= o execute 32-bit code and then transit back to long mode. =20 @param[in] Function The 32bit code entry to be executed. @@ -29,6 +29,22 @@ Execute32BitCode ( IN UINT64 Param2 ); =20 +/** + Wrapper to execute 64-bit code directly from long mode. + + @param[in] Function The 64bit code entry to be executed. + @param[in] Param1 The first parameter to pass to 64bit code. + @param[in] Param2 The second parameter to pass to 64bit code. + + @return EFI_STATUS. +**/ +EFI_STATUS +Execute64BitCode ( + IN UINT64 Function, + IN UINT64 Param1, + IN UINT64 Param2 + ); + /** Find FSP header pointer. =20 @@ -94,7 +110,11 @@ CallFspNotifyPhase ( =20 NotifyPhaseApi =3D (FSP_NOTIFY_PHASE)((UINTN)FspHeader->ImageBase + FspH= eader->NotifyPhaseEntryOffset); InterruptState =3D SaveAndDisableInterrupts (); - Status =3D Execute32BitCode ((UINTN)NotifyPhaseApi, (UINTN)Notif= yPhaseParams, (UINTN)NULL); + if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) =3D= =3D FSP_IA32) { + Status =3D Execute32BitCode ((UINTN)NotifyPhaseApi, (UINTN)NotifyPhase= Params, (UINTN)NULL); + } else { + Status =3D Execute64BitCode ((UINTN)NotifyPhaseApi, (UINTN)NotifyPhase= Params, (UINTN)NULL); + } SetInterruptState (InterruptState); =20 return Status; @@ -127,7 +147,11 @@ CallFspMemoryInit ( =20 FspMemoryInitApi =3D (FSP_MEMORY_INIT)((UINTN)FspHeader->ImageBase + Fsp= Header->FspMemoryInitEntryOffset); InterruptState =3D SaveAndDisableInterrupts (); - Status =3D Execute32BitCode ((UINTN)FspMemoryInitApi, (UINTN)F= spmUpdDataPtr, (UINTN)HobListPtr); + if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) =3D= =3D FSP_IA32) { + Status =3D Execute32BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDa= taPtr, (UINTN)HobListPtr); + } else { + Status =3D Execute64BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDa= taPtr, (UINTN)HobListPtr); + } SetInterruptState (InterruptState); =20 return Status; @@ -158,7 +182,11 @@ CallTempRamExit ( =20 TempRamExitApi =3D (FSP_TEMP_RAM_EXIT)((UINTN)FspHeader->ImageBase + Fsp= Header->TempRamExitEntryOffset); InterruptState =3D SaveAndDisableInterrupts (); - Status =3D Execute32BitCode ((UINTN)TempRamExitApi, (UINTN)TempR= amExitParam, (UINTN)NULL); + if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) =3D= =3D FSP_IA32) { + Status =3D Execute32BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExit= Param, (UINTN)NULL); + } else { + Status =3D Execute64BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExit= Param, (UINTN)NULL); + } SetInterruptState (InterruptState); =20 return Status; @@ -189,7 +217,11 @@ CallFspSiliconInit ( =20 FspSiliconInitApi =3D (FSP_SILICON_INIT)((UINTN)FspHeader->ImageBase + F= spHeader->FspSiliconInitEntryOffset); InterruptState =3D SaveAndDisableInterrupts (); - Status =3D Execute32BitCode ((UINTN)FspSiliconInitApi, (UINTN= )FspsUpdDataPtr, (UINTN)NULL); + if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) =3D= =3D FSP_IA32) { + Status =3D Execute32BitCode ((UINTN)FspSiliconInitApi, (UINTN)FspsUpdD= ataPtr, (UINTN)NULL); + } else { + Status =3D Execute64BitCode ((UINTN)FspSiliconInitApi, (UINTN)FspsUpdD= ataPtr, (UINTN)NULL); + } SetInterruptState (InterruptState); =20 return Status; diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/Dispatch= Execute.c b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchE= xecute.c index 4f6a8dd1a7..a17ca7dcab 100644 --- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute= .c +++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute= .c @@ -1,7 +1,7 @@ /** @file Execute 32-bit code in Protected Mode. =20 - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -49,3 +49,24 @@ Execute32BitCode ( =20 return Status; } + +/** + Wrapper for a thunk to transition from compatibility mode to long mode t= o execute 64-bit code and then transit back to + compatibility mode. + + @param[in] Function The 64bit code entry to be executed. + @param[in] Param1 The first parameter to pass to 64bit code. + @param[in] Param2 The second parameter to pass to 64bit code. + + @return EFI_STATUS. +**/ +EFI_STATUS +Execute64BitCode ( + IN UINT64 Function, + IN UINT64 Param1, + IN UINT64 Param2 + ) +{ + return EFI_UNSUPPORTED; +} + diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/DispatchE= xecute.c b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/DispatchExe= cute.c index 2ee5bc3dd4..591a5c7a55 100644 --- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/DispatchExecute.c +++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/DispatchExecute.c @@ -1,9 +1,9 @@ /** @file - Execute 32-bit code in Long Mode. + Execute 64-bit code in Long Mode. Provide a thunk function to transition from long mode to compatibility m= ode to execute 32-bit code and then transit back to long mode. =20 - Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -12,6 +12,21 @@ #include #include =20 +/** + FSP API functions. + + @param[in] Param1 The first parameter to pass to 64bit code. + @param[in] Param2 The second parameter to pass to 64bit code. + + @return EFI_STATUS. +**/ +typedef +EFI_STATUS +(EFIAPI *FSP_FUNCTION)( + IN VOID *Param1, + IN VOID *Param2 + ); + #pragma pack(1) typedef union { struct { @@ -80,7 +95,7 @@ AsmExecute32BitCode ( ); =20 /** - Wrapper for a thunk to transition from long mode to compatibility mode = to execute 32-bit code and then transit back to + Wrapper for a thunk to transition from long mode to compatibility mode t= o execute 32-bit code and then transit back to long mode. =20 @param[in] Function The 32bit code entry to be executed. @@ -110,3 +125,29 @@ Execute32BitCode ( =20 return Status; } + +/** + Wrapper to execute 64-bit code directly from long mode. + + @param[in] Function The 64bit code entry to be executed. + @param[in] Param1 The first parameter to pass to 64bit code. + @param[in] Param2 The second parameter to pass to 64bit code. + + @return EFI_STATUS. +**/ +EFI_STATUS +Execute64BitCode ( + IN UINT64 Function, + IN UINT64 Param1, + IN UINT64 Param2 + ) +{ + FSP_FUNCTION EntryFunc; + EFI_STATUS Status; + + EntryFunc =3D (FSP_FUNCTION)(UINTN)(Function); + Status =3D EntryFunc ((VOID *)(UINTN)Param1, (VOID *)(UINTN)Param2); + + return Status; +} + --=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 (#88935): https://edk2.groups.io/g/devel/message/88935 Mute This Topic: https://groups.io/mt/90482854/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 Wed May 15 03:39:09 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+88936+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+88936+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1650011887; cv=none; d=zohomail.com; s=zohoarc; b=WrexWZbL5/lsIFzVDYjGI6U8b6mP8s3bxCTHwL59XiAdccyxaF9ROegfwjTaLbdG/tuzqf88p0goFGc3hI3UL1DjD4hln7OqX/o3lxUA8ksxUO4z/bccPjOvLCiNJbIwOSx+QKtww2SJVJBukq1IuRgXHPVAeN8sjbdlBRzCygg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650011887; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=gqWODsLQDDY8+viqx+DmrIKcQxSiSmIeio6BqDZHd6Y=; b=PTZDtsjEAQBRyLf1yTLKsyW9spNyutSXbSN924NqnRYyBWMa2xm297dFZBgwXLM2+rybpgX4ka59azcKH6yl1ycd8rD1wSBSl1fLGldq+Y9FOVtzQl4cz2Zip1UChdiwEkc05iI9m1A4/uIo0OMtLQgDLR95MZrLVbvIgeYcEnE= 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+88936+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 1650011887465525.5409577027115; Fri, 15 Apr 2022 01:38:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vGXgYY1788612x0Ou9RDwPSY; Fri, 15 Apr 2022 01:38:07 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5019.1650011880994981369 for ; Fri, 15 Apr 2022 01:38:06 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262563869" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="262563869" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:05 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="700990512" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 01:38:04 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v5 8/8] IntelFsp2WrapperPkg: SecFspWrapperPlatformSecLibSample support for X64 Date: Fri, 15 Apr 2022 16:37:43 +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: Xo7Kn88sgsHjNMyEEqUlCTysx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1650011887; bh=885bdGDSFegU4FBE/Ifx9tdwt6UQH/jsoaJ7AzzAPp0=; h=Cc:Date:From:Reply-To:Subject:To; b=G91IusCRigKCRGWgAckrUWl+llcfrt8bYbj0nySplL2VgEoLimsS+Niyqmvz9f0M9gS /8ZBCASgAQdWSq7LpBxOAr1+9GNzwJ8xRY1Cj8bzvfHktGq/BP/Oo5B9iXMdD9iC1neRK GYRf1gyWHSyhfZ82/AGuy5dJkGfsWJSQew4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1650011888382100035 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 SecFspWrapperPlatformSecLibSample support for X64. 2.Adopted FSPT_ARCH2_UPD in SecFspWrapperPlatformSecLibSample. 3.Moved Fsp.h up one level to be shared across IA32 and X64. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo Reviewed-by: Nate DeSimone --- .../{Ia32 =3D> }/Fsp.h | 0 .../Ia32/Stack.nasm | 8 +- .../SecFspWrapperPlatformSecLibSample.inf | 9 +- .../SecRamInitData.c | 24 +-- .../X64/PeiCoreEntry.nasm | 149 ++++++++++++++++++ .../X64/SecEntry.nasm | 171 +++++++++++++++++= ++++ .../X64/Stack.nasm | 73 +++++++++ 7 files changed, 418 insertions(+), 16 deletions(-) rename IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/{Ia32= =3D> }/Fsp.h (100%) create mode 100644 IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLib= Sample/X64/PeiCoreEntry.nasm create mode 100644 IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLib= Sample/X64/SecEntry.nasm create mode 100644 IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLib= Sample/X64/Stack.nasm diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= Ia32/Fsp.h b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= Fsp.h similarity index 100% rename from IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/I= a32/Fsp.h rename to IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Fsp= .h diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= Ia32/Stack.nasm b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSa= mple/Ia32/Stack.nasm index d7394cf286..eb5b120816 100644 --- a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/St= ack.nasm +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/St= ack.nasm @@ -1,6 +1,6 @@ ;-------------------------------------------------------------------------= ----- ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Abstract: @@ -22,7 +22,7 @@ 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/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= SecFspWrapperPlatformSecLibSample.inf b/IntelFsp2WrapperPkg/Library/SecFspW= rapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf index 027b127724..28a8602b03 100644 --- a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspW= rapperPlatformSecLibSample.inf +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspW= rapperPlatformSecLibSample.inf @@ -1,7 +1,7 @@ ## @file # Sample to provide FSP wrapper platform sec related function. # -# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -39,13 +39,18 @@ SecGetPerformance.c SecTempRamDone.c PlatformInit.c + Fsp.h =20 [Sources.IA32] - Ia32/Fsp.h Ia32/SecEntry.nasm Ia32/PeiCoreEntry.nasm Ia32/Stack.nasm =20 +[Sources.X64] + X64/SecEntry.nasm + X64/PeiCoreEntry.nasm + X64/Stack.nasm + ##########################################################################= ###### # # Package Dependency Section - list of Package files that are required for diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= SecRamInitData.c b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibS= ample/SecRamInitData.c index 03616cb418..d2acb2fd46 100644 --- a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamI= nitData.c +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamI= nitData.c @@ -1,7 +1,7 @@ /** @file Sample to provide TempRamInitParams data. =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -10,18 +10,20 @@ #include =20 typedef struct { - UINT32 MicrocodeRegionBase; - UINT32 MicrocodeRegionSize; - UINT32 CodeRegionBase; - UINT32 CodeRegionSize; + EFI_PHYSICAL_ADDRESS MicrocodeRegionBase; + UINT64 MicrocodeRegionSize; + EFI_PHYSICAL_ADDRESS CodeRegionBase; + UINT64 CodeRegionSize; } FSPT_CORE_UPD; =20 typedef struct { FSP_UPD_HEADER FspUpdHeader; // - // If platform does not support FSP spec 2.2 remove FSPT_ARCH_UPD struct= ure. + // If FSP spec version < 2.2, remove FSPT_ARCH_UPD structure. + // Else If FSP spec version >=3D 2.2 and FSP spec version < 2.4, use FSP= T_ARCH_UPD structure. + // Else, use FSPT_ARCH2_UPD structure. // - FSPT_ARCH_UPD FsptArchUpd; + FSPT_ARCH2_UPD FsptArchUpd; FSPT_CORE_UPD FsptCoreUpd; } FSPT_UPD_CORE_DATA; =20 @@ -36,10 +38,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST FSPT_UPD_CORE_DATA = FsptUpdDataPtr =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, // - // If platform does not support FSP spec 2.2 remove FSPT_ARCH_UPD struct= ure. + // If FSP spec version < 2.2, remove FSPT_ARCH_UPD structure. + // Else If FSP spec version >=3D 2.2 and FSP spec version < 2.4, use FSP= T_ARCH_UPD structure. + // Else, use FSPT_ARCH2_UPD structure. // { - 0x01, + 0x02, { 0x00, 0x00, 0x00 }, @@ -47,7 +51,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST FSPT_UPD_CORE_DATA F= sptUpdDataPtr =3D { 0x00000000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, { diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= X64/PeiCoreEntry.nasm b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSe= cLibSample/X64/PeiCoreEntry.nasm new file mode 100644 index 0000000000..0c0766acb8 --- /dev/null +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/Pei= CoreEntry.nasm @@ -0,0 +1,149 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Module Name: +; +; PeiCoreEntry.nasm +; +; Abstract: +; +; Find and call SecStartup +; +;-------------------------------------------------------------------------= ----- + +SECTION .text + +%include "PushPopRegsNasm.inc" + +extern ASM_PFX(SecStartup) +extern ASM_PFX(PlatformInit) + +; +; args 1:XMM, 2:REG, 3:IDX +; +%macro LXMMN 3 + pextrq %2, %1, (%3 & 3) + %endmacro + +; +; args 1:YMM, 2:XMM, 3:IDX (0 - lower 128bits, 1 - upper 128bits) +; +%macro LYMMN 3 + vextractf128 %2, %1, %3 + %endmacro + +%macro LOAD_TS 1 + LYMMN ymm6, xmm5, 1 + LXMMN xmm5, %1, 1 + %endmacro + +global ASM_PFX(CallPeiCoreEntryPoint) +ASM_PFX(CallPeiCoreEntryPoint): + ; + ; Per X64 calling convention, make sure RSP is 16-byte aligned. + ; + mov rax, rsp + and rax, 0fh + sub rsp, rax + + ; + ; Platform init + ; + PUSHA_64 + sub rsp, 20h + call ASM_PFX(PlatformInit) + add rsp, 20h + POPA_64 + + ; + ; Set stack top pointer + ; + mov rsp, r8 + + ; + ; Push the hob list pointer + ; + push rcx + + ; + ; RBP holds start of BFV passed from Vtf0. Save it to r10. + ; + mov r10, rbp + + ; + ; Save the value + ; RDX: start of range + ; r8: end of range + ; + mov rbp, rsp + push rdx + push r8 + mov r14, rdx + mov r15, r8 + + ; + ; Push processor count to stack first, then BIST status (AP then BSP) + ; + mov eax, 1 + cpuid + shr ebx, 16 + and ebx, 0000000FFh + cmp bl, 1 + jae PushProcessorCount + + ; + ; Some processors report 0 logical processors. Effectively 0 =3D 1. + ; So we fix up the processor count + ; + inc ebx + +PushProcessorCount: + sub rsp, 4 + mov rdi, rsp + mov DWORD [rdi], ebx + + ; + ; We need to implement a long-term solution for BIST capture. For now, = we just copy BSP BIST + ; for all processor threads + ; + xor ecx, ecx + mov cl, bl +PushBist: + sub rsp, 4 + mov rdi, rsp + movd eax, mm0 + mov DWORD [rdi], eax + loop PushBist + + ; Save Time-Stamp Counter + LOAD_TS rax + push rax + + ; + ; Pass entry point of the PEI core + ; + mov rdi, 0FFFFFFE0h + mov edi, DWORD [rdi] + mov r9, rdi + + ; + ; Pass BFV into the PEI Core + ; + mov r8, r10 + + ; + ; Pass stack size into the PEI Core + ; + mov rcx, r15 ; Start of TempRam + mov rdx, r14 ; End of TempRam + + sub rcx, rdx ; Size of TempRam + + ; + ; Pass Control into the PEI Core + ; + sub rsp, 20h + call ASM_PFX(SecStartup) + diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= X64/SecEntry.nasm b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLib= Sample/X64/SecEntry.nasm new file mode 100644 index 0000000000..dbbf63336e --- /dev/null +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/Sec= Entry.nasm @@ -0,0 +1,171 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Module Name: +; +; SecEntry.asm +; +; Abstract: +; +; This is the code that calls TempRamInit API from FSP binary and passes +; control into PEI core. +; +;-------------------------------------------------------------------------= ----- + +#include "Fsp.h" + +IA32_CR4_OSFXSR equ 200h +IA32_CR4_OSXMMEXCPT equ 400h +IA32_CR0_MP equ 2h + +IA32_CPUID_SSE2 equ 02000000h +IA32_CPUID_SSE2_B equ 26 + +SECTION .text + +extern ASM_PFX(CallPeiCoreEntryPoint) +extern ASM_PFX(FsptUpdDataPtr) + +; Pcds +extern ASM_PFX(PcdGet32 (PcdFsptBaseAddress)) + +;-------------------------------------------------------------------------= --- +; +; Procedure: _ModuleEntryPoint +; +; Input: None +; +; Output: None +; +; Destroys: Assume all registers +; +; Description: +; +; Call TempRamInit API from FSP binary. After TempRamInit done, pass +; control into PEI core. +; +; Return: None +; +; MMX Usage: +; MM0 =3D BIST State +; +;-------------------------------------------------------------------------= --- + +BITS 64 +align 16 +global ASM_PFX(ModuleEntryPoint) +ASM_PFX(ModuleEntryPoint): + fninit ; clear any pending Floating point= exceptions + ; + ; Store the BIST value in mm0 + ; + movd mm0, eax + + ; Find the fsp info header + mov rax, ASM_PFX(PcdGet32 (PcdFsptBaseAddress)) + mov edi, [eax] + + mov eax, dword [edi + FVH_SIGINATURE_OFFSET] + cmp eax, FVH_SIGINATURE_VALID_VALUE + jnz FspHeaderNotFound + + xor eax, eax + mov ax, word [edi + FVH_EXTHEADER_OFFSET_OFFSET] + cmp ax, 0 + jnz FspFvExtHeaderExist + + xor eax, eax + mov ax, word [edi + FVH_HEADER_LENGTH_OFFSET] ; Bypass Fv Header + add edi, eax + jmp FspCheckFfsHeader + +FspFvExtHeaderExist: + add edi, eax + mov eax, dword [edi + FVH_EXTHEADER_SIZE_OFFSET] ; Bypass Ext Fv He= ader + add edi, eax + + ; Round up to 8 byte alignment + mov eax, edi + and al, 07h + jz FspCheckFfsHeader + + and edi, 0FFFFFFF8h + add edi, 08h + +FspCheckFfsHeader: + ; Check the ffs guid + mov eax, dword [edi] + cmp eax, FSP_HEADER_GUID_DWORD1 + jnz FspHeaderNotFound + + mov eax, dword [edi + 4] + cmp eax, FSP_HEADER_GUID_DWORD2 + jnz FspHeaderNotFound + + mov eax, dword [edi + 8] + cmp eax, FSP_HEADER_GUID_DWORD3 + jnz FspHeaderNotFound + + mov eax, dword [edi + 0Ch] + cmp eax, FSP_HEADER_GUID_DWORD4 + jnz FspHeaderNotFound + + add edi, FFS_HEADER_SIZE_VALUE ; Bypass the ffs header + + ; Check the section type as raw section + mov al, byte [edi + SECTION_HEADER_TYPE_OFFSET] + cmp al, 019h + jnz FspHeaderNotFound + + add edi, RAW_SECTION_HEADER_SIZE_VALUE ; Bypass the section header + jmp FspHeaderFound + +FspHeaderNotFound: + jmp $ + +FspHeaderFound: + ; Get the fsp TempRamInit Api address + mov eax, dword [edi + FSP_HEADER_IMAGEBASE_OFFSET] + add eax, dword [edi + FSP_HEADER_TEMPRAMINIT_OFFSET] + + ; Setup the hardcode stack + mov rsp, TempRamInitStack + + ; Call the fsp TempRamInit Api + jmp rax + +TempRamInitDone: + cmp rax, 0800000000000000Eh ; Check if EFI_NOT_FOUND returned. Error= code for Microcode Update not found. + je CallSecFspInit ; If microcode not found, don't hang, bu= t continue. + + cmp rax, 0 ; Check if EFI_SUCCESS returned. + jnz FspApiFailed + + ; RDX: start of range + ; R8: end of range +CallSecFspInit: + + mov r8, rdx + mov rdx, rcx + xor ecx, ecx ; zero - no Hob List Yet + mov rsp, r8 + + ; + ; Per X64 calling convention, make sure RSP is 16-byte aligned. + ; + mov rax, rsp + and rax, 0fh + sub rsp, rax + + call ASM_PFX(CallPeiCoreEntryPoint) + +FspApiFailed: + jmp $ + +align 10h +TempRamInitStack: + DQ TempRamInitDone + DQ ASM_PFX(FsptUpdDataPtr) ; TempRamInitParams + diff --git a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/= X64/Stack.nasm b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSam= ple/X64/Stack.nasm new file mode 100644 index 0000000000..64e46ce953 --- /dev/null +++ b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/Sta= ck.nasm @@ -0,0 +1,73 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Abstract: +; +; Switch the stack from temporary memory to permanent memory. +; +;-------------------------------------------------------------------------= ----- + + SECTION .text + +;-------------------------------------------------------------------------= ----- +; VOID +; EFIAPI +; SecSwitchStack ( +; UINT32 TemporaryMemoryBase, +; UINT32 PermanentMemoryBase +; ); +;-------------------------------------------------------------------------= ----- +global ASM_PFX(SecSwitchStack) +ASM_PFX(SecSwitchStack): + ; + ; Save four register: rax, rbx, rcx, rdx + ; + push rax + push rbx + push rcx + push rdx + + ; + ; !!CAUTION!! this function address's is pushed into stack after + ; migration of whole temporary memory, so need save it to permanent + ; memory at first! + ; + + mov rbx, rcx ; Save the first parameter + mov rcx, rdx ; Save the second parameter + + ; + ; Save this function's return address into permanent memory at first. + ; Then, Fixup the esp point to permanent memory + ; + mov rax, rsp + sub rax, rbx + add rax, rcx + mov rdx, qword [rsp] ; copy pushed register's value to perma= nent memory + mov qword [rax], rdx + mov rdx, qword [rsp + 8] + mov qword [rax + 8], rdx + mov rdx, qword [rsp + 16] + mov qword [rax + 16], rdx + mov rdx, qword [rsp + 24] + mov qword [rax + 24], rdx + mov rdx, qword [rsp + 32] ; Update this function's return address= into permanent memory + mov qword [rax + 32], rdx + mov rsp, rax ; From now, rsp is pointed to permanent= memory + + ; + ; Fixup the rbp point to permanent memory + ; + mov rax, rbp + sub rax, rbx + add rax, rcx + mov rbp, rax ; From now, rbp is pointed to permanent= memory + + pop rdx + pop rcx + pop rbx + pop rax + ret + --=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 (#88936): https://edk2.groups.io/g/devel/message/88936 Mute This Topic: https://groups.io/mt/90482855/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-