From nobody Sat May 18 04:13:32 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+86633+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+86633+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1644768199; cv=none; d=zohomail.com; s=zohoarc; b=WrOlQhbiauaDd2F9DBXu4kJU5b65hRyVoRKB2bnfoG4hMXhnepB95rhc4jyOQC551mB+Aw7gZDfuL1Knot9fZ/cGuWntqChLSxPpHMWEaunr8fpfMOBw8GArHbYgplC2PH3KBTsSwHTYDayii6vZLyqvjxNgShtG/tXSKQNDOH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644768199; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=OPQciWHmU3/K7tlmJFW8CSf5v51exFAeHBxJ4wsvBGc=; b=RmDeTjAcKwU0mnFzW8LIAQFqwlRn14TYBspXtWibIIwfVc1rAQ7rapeH08VeBjeCMwyhTCEGXRjOIOhNSQnhSkUYNujOT1yYz6q1hRG8K5FfLuEl7ol0U6i7cvsD9lYYMY+Gtyp/AMJRKmKdz6TcuUfH4uWicWgd4kN/l0cOWkU= 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+86633+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 1644768199180209.478467930806; Sun, 13 Feb 2022 08:03:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZNqbYY1788612xTBt3AADaD8; Sun, 13 Feb 2022 08:03:18 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.22799.1644768197714598826 for ; Sun, 13 Feb 2022 08:03:18 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10256"; a="247551819" X-IronPort-AV: E=Sophos;i="5.88,365,1635231600"; d="scan'208";a="247551819" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 08:03:16 -0800 X-IronPort-AV: E=Sophos;i="5.88,365,1635231600"; d="scan'208";a="631636605" X-Received: from basfe004.gar.corp.intel.com ([10.66.129.57]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 08:03:13 -0800 From: "Ashraf Ali S" To: devel@edk2.groups.io Cc: Ashraf Ali S , Chasel Chiu , Nate DeSimone , Star Zeng , Kuo Ted , Duggapu Chinni B , Rangasai V Chaganty , Digant H Solanki , Sangeetha V Subject: [edk2-devel] [PATCH] IntelFsp2Pkg: BaseFspSwitchStackLib Support for X64 Build Date: Sun, 13 Feb 2022 21:31:45 +0530 Message-Id: <1854878485cb78c405c11f72e6ca7363587cac73.1644768023.git.ashraf.ali.s@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ashraf.ali.s@intel.com X-Gm-Message-State: FrQF4h6bJBy7nBu0TA4sfencx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1644768198; bh=A2VFY+mPomg+v4bQTQhYQXBNPj3Q/zBAQeD8gtoXPYU=; h=Cc:Date:From:Reply-To:Subject:To; b=Ar0wpsfVCPJJ4ebhXM8jH6C13gk58hwT7s7tMo+lbMqceMc2dJPY3cl4X+wleCl+suC eYhmS/yVBoJttvhbQ2QpyYPDHlAMNnJA9XyYWqo4Jm653ETiJ9xfEXGyyaRWUYX73ZJtF EXqz2cltKaz74GraFiSGswIJ5k/9uB0RWmI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1644768200351100001 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3832 BaseFspSwitchStackLib Currently Support for IA32 build only, adding support for X64 build, fix typecasting issues for X64 build. 0xFFFF_FFFF will be replaced by MAX_ADDRESS which is set based on the type of Library which is it building. if it's a IA32 MAX_ADDRESS =3D 0xFFFF_FFFF for X64 MAX_ADDRESS =3D 0xFFFF_FFFF_FFFF_FFFFULL Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Kuo Ted Cc: Duggapu Chinni B Cc: Rangasai V Chaganty Cc: Digant H Solanki Cc: Sangeetha V Signed-off-by: Ashraf Ali S --- IntelFsp2Pkg/FspSecCore/SecFsp.h | 3 +- IntelFsp2Pkg/FspSecCore/SecFspApiChk.c | 10 +- .../BaseFspSwitchStackLib.inf | 7 +- .../BaseFspSwitchStackLib/X64/Stack.nasm | 124 ++++++++++++++++++ 4 files changed, 136 insertions(+), 8 deletions(-) create mode 100644 IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.na= sm diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.h index aacd32f7f7..9a6fc14d23 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 **/ @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c b/IntelFsp2Pkg/FspSecCo= re/SecFspApiChk.c index 7d6ef11fe7..b70d3ffcf1 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)) { 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) { 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)) { 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)) { Status =3D EFI_UNSUPPORTED; } else { if (FspData->Signature !=3D FSP_GLOBAL_DATA_SIGNATURE) { diff --git a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackL= ib.inf b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.i= nf index 3dcf3b9598..cd7d89e43a 100644 --- a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf +++ b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf @@ -1,7 +1,7 @@ ## @file # Instance of BaseFspSwitchStackLib # -# 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 # @@ -15,12 +15,15 @@ VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D FspSwitchStackLib =20 -[Sources.IA32] +[Sources] FspSwitchStackLib.c =20 [Sources.IA32] Ia32/Stack.nasm =20 +[Sources.X64] + X64/Stack.nasm + [Packages] MdePkg/MdePkg.dec IntelFsp2Pkg/IntelFsp2Pkg.dec diff --git a/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm b/In= telFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm new file mode 100644 index 0000000000..f94f39fc13 --- /dev/null +++ b/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/X64/Stack.nasm @@ -0,0 +1,124 @@ +;-------------------------------------------------------------------------= ----- +; +; 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 + +extern ASM_PFX(SwapStack) + +;-------------------------------------------------------------------------= ---- +; Macro: PUSHA_64 +; +; Description: Saves all registers on stack +; +; Input: None +; +; Output: None +;-------------------------------------------------------------------------= ---- +%macro PUSHA_64 0 + push rsp + push rbp + push rax + push rbx + push rcx + push rdx + push rsi + push rdi + push r8 + push r9 + push r10 + push r11 + push r12 + push r13 + push r14 + push r15 +%endmacro + +;-------------------------------------------------------------------------= ---- +; Macro: POPA_64 +; +; Description: Restores all registers from stack +; +; Input: None +; +; Output: None +;-------------------------------------------------------------------------= ---- +%macro POPA_64 0 + pop r15 + pop r14 + pop r13 + pop r12 + pop r11 + pop r10 + pop r9 + pop r8 + pop rdi + pop rsi + pop rdx + pop rcx + pop rbx + pop rax + pop rbp + pop rsp +%endmacro + +;-------------------------------------------------------------------------= ----- +; UINT32 +; EFIAPI +; Pei2LoaderSwitchStack ( +; VOID +; ) +;-------------------------------------------------------------------------= ----- +global ASM_PFX(Pei2LoaderSwitchStack) +ASM_PFX(Pei2LoaderSwitchStack): + xor rax, rax + jmp ASM_PFX(FspSwitchStack) + +;-------------------------------------------------------------------------= ----- +; UINT32 +; EFIAPI +; Loader2PeiSwitchStack ( +; VOID +; ) +;-------------------------------------------------------------------------= ----- +global ASM_PFX(Loader2PeiSwitchStack) +ASM_PFX(Loader2PeiSwitchStack): + jmp ASM_PFX(FspSwitchStack) + +;-------------------------------------------------------------------------= ----- +; UINT32 +; EFIAPI +; FspSwitchStack ( +; VOID +; ) +;-------------------------------------------------------------------------= ----- +global ASM_PFX(FspSwitchStack) +ASM_PFX(FspSwitchStack): + ; Save current contexts + push rax + pushfq + cli + PUSHA_64 + sub esp, 8 + sidt [esp] + + ; Load new stack + mov rcx, rsp + call ASM_PFX(SwapStack) + mov rsp, rax + + ; Restore previous contexts + lidt [esp] + add esp, 8 + POPA_64 + popfq + add esp, 4 + ret + --=20 2.30.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 (#86633): https://edk2.groups.io/g/devel/message/86633 Mute This Topic: https://groups.io/mt/89115596/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-