From nobody Sun Feb 8 09:27:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97507+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+97507+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1671194828; cv=none; d=zohomail.com; s=zohoarc; b=PD47OSrgCNqKlI/YTjABSvJeoz5wt5XQa30T9CnysWTcE+mWOH+E+Mnc6TtqjWIU0qYvYVL7x8xmKoQWsqXWGagaTL0W7thu5/43GpNLK05hlXBhP9NBlDhigYtXJ+QbppIMPeFiZp4jiIxSRl8p7Vmi2tcJZ/LL502c1CXtxD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671194828; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=RNWYXSbJ/WUPf6PucshlI1y2kv2Q4menD4CKFlxZ750=; b=d7gKsZVlibRu28zZF/VtAzdZizIxfcPlwsZhV6088Z6ytKF0h/qLSRhSh3ozc1nU2fpSf03rr2lpqgVWiBiP/7hkka0xm362mxANv0fADTzavs9TYpDHKfUhWP+UTdYOyO/cfIWyXStlNgCexO5Wa3BFKOS8TZ9G57neObIIeSU= 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+97507+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 1671194828222807.5280550397986; Fri, 16 Dec 2022 04:47:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id GEEeYY1788612xiHYFmht5bX; Fri, 16 Dec 2022 04:47:07 -0800 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.11870.1671194824336805327 for ; Fri, 16 Dec 2022 04:47:07 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="346041901" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="346041901" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2022 04:47:07 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="738526331" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="738526331" X-Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.0]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2022 04:47:05 -0800 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Ray Ni , Zhiguang Liu , Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S , Chinni B Duggapu Subject: [edk2-devel][PATCH v2 2/2] MdeModulePkg: Supporting S3 in 64bit PEI Date: Fri, 16 Dec 2022 20:46:27 +0800 Message-Id: <353372049f40d2d7408f45f867fa48db87a8f95a.1671194636.git.ted.kuo@intel.com> In-Reply-To: References: 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,ted.kuo@intel.com X-Gm-Message-State: nkfqHyv2L9n8AQCaTRihuHzcx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1671194827; bh=ZublrJNVvcA8BS5WDmcweNrWtDSHia/vlEHCT6lrAZo=; h=Cc:Date:From:Reply-To:Subject:To; b=JltEMsAo3seML0p+Igj3XN/dpRWoSPXhfNwhUnpwLIIkgNpz8NhB/nr9RtiXKGfskj3 +a5Cr5PsIpHZWIodpWO2SpBoECTVNbEt5jaQsaZoVh8RbrD8oJeMmZyIK3IfSY//lOVSV QgMCwt6EI3RpsJUclUymc9/iWfJ1g3tav94= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1671194829441100007 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D4195 Transfer from DXE to OS waking vector by calling SwitchStack() when both are in the same execution mode. Cc: Ray Ni Cc: Zhiguang Liu Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Cc: Chinni B Duggapu Signed-off-by: Ted Kuo --- .../BootScriptExecutorDxe/ScriptExecute.c | 21 +++++++++++++------ .../BootScriptExecutorDxe/X64/SetIdtEntry.c | 4 ++-- .../Acpi/S3SaveStateDxe/AcpiS3ContextSave.c | 10 ++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecut= e.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index 82481aacd6..98c5abecf8 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c @@ -4,7 +4,7 @@ This driver is dispatched by Dxe core and the driver will reload itself = to ACPI reserved memory in the entry point. The functionality is to interpret and restore the S3= boot script =20 -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -95,7 +95,7 @@ S3BootScriptExecutorEntryFunction ( PeiS3ResumeState->ReturnStatus =3D (UINT64)(UINTN)Status; if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { // - // X64 S3 Resume + // X64 DXE to IA32 PEI S3 Resume // DEBUG ((DEBUG_INFO, "Call AsmDisablePaging64() to return to S3 Resum= e in PEI Phase\n")); PeiS3ResumeState->AsmTransferControl =3D (EFI_PHYSICAL_ADDRESS)(UINT= N)AsmTransferControl32; @@ -121,7 +121,7 @@ S3BootScriptExecutorEntryFunction ( ); } else { // - // IA32 S3 Resume + // IA32 DXE to IA32 PEI S3 Resume / X64 DXE to X64 PEI S3 Resume // DEBUG ((DEBUG_INFO, "Call SwitchStack() to return to S3 Resume in PE= I Phase\n")); PeiS3ResumeState->AsmTransferControl =3D (EFI_PHYSICAL_ADDRESS)(UINT= N)AsmTransferControl; @@ -156,8 +156,11 @@ S3BootScriptExecutorEntryFunction ( // // X64 long mode waking vector // - DEBUG ((DEBUG_INFO, "Transfer to 64bit OS waking vector - %x\r\n", (= UINTN)Facs->XFirmwareWakingVector)); - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + DEBUG ((DEBUG_INFO, "Transfer from 64bit DXE to 64bit OS waking vect= or - %x\r\n", (UINTN)Facs->XFirmwareWakingVector)); + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { + // + // 64bit DXE calls to 64bit OS S3 waking vector + // SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)Facs->XFirmwareWakingVector, NULL, @@ -174,7 +177,10 @@ S3BootScriptExecutorEntryFunction ( // IA32 protected mode waking vector (Page disabled) // DEBUG ((DEBUG_INFO, "Transfer to 32bit OS waking vector - %x\r\n", (= UINTN)Facs->XFirmwareWakingVector)); - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { + // + // 64bit DXE calls to 32bit OS S3 waking vector + // AsmDisablePaging64 ( 0x10, (UINT32)Facs->XFirmwareWakingVector, @@ -183,6 +189,9 @@ S3BootScriptExecutorEntryFunction ( (UINT32)TempStackTop ); } else { + // + // 32bit DXE calls to 32bit OS S3 waking vector + // SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)Facs->XFirmwareWakingVector, NULL, diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEn= try.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c index 6b44f50bac..7fc6cdcb4e 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c @@ -3,7 +3,7 @@ =20 Set a IDT entry for interrupt vector 3 for debug purpose for x64 platform =20 -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 =20 @@ -118,7 +118,7 @@ IsLongModeWakingVector ( ((Facs->OspmFlags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) !=3D 0)) { // Both BIOS and OS wants 64bit vector - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { return TRUE; } } diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c= b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c index 03f7a332d3..70bee7a67b 100644 --- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c +++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c @@ -1,7 +1,7 @@ /** @file This is the implementation to save ACPI S3 Context. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -97,7 +97,7 @@ IsLongModeWakingVectorSupport ( // // BIOS supports 64bit waking vector. // - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { return TRUE; } } @@ -110,11 +110,11 @@ IsLongModeWakingVectorSupport ( =20 @param[in] LongModeWakingVectorSupport Support long mode waking vecto= r or not. =20 - If BootScriptExector driver will run in 64-bit mode, this function will = establish the 1:1 + If BootScriptExecutor driver will run in 64-bit mode, this function will= establish the 1:1 virtual to physical mapping page table when long mode waking vector is s= upported, otherwise create 4G page table when long mode waking vector is not supported and l= et PF handler to handle > 4G request. - If BootScriptExector driver will not run in 64-bit mode, this function w= ill do nothing. + If BootScriptExecutor driver will not run in 64-bit mode, this function = will do nothing. =20 @return Page table base address. =20 @@ -124,7 +124,7 @@ S3AllocatePageTablesBuffer ( IN BOOLEAN LongModeWakingVectorSupport ) { - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + if ((FeaturePcdGet (PcdDxeIplSwitchToLongMode)) || (sizeof (UINTN) =3D= =3D sizeof (UINT64))) { UINTN ExtraPageTablePages; UINT32 RegEax; UINT32 RegEdx; --=20 2.35.3.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 (#97507): https://edk2.groups.io/g/devel/message/97507 Mute This Topic: https://groups.io/mt/95708650/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-