From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D4AAC21EA15CD for ; Tue, 10 Oct 2017 22:51:34 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 10 Oct 2017 22:55:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="161291436" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 10 Oct 2017 22:55:02 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Oct 2017 22:55:02 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Oct 2017 22:55:01 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Wed, 11 Oct 2017 13:54:59 +0800 From: "Dong, Eric" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. Thread-Index: AQHTQkB1O5w6LpeJXUKlbn7GJyE9GaLeItLQ Date: Wed, 11 Oct 2017 05:54:58 +0000 Message-ID: References: <1507688554-10264-1-git-send-email-eric.dong@intel.com> <1507688554-10264-3-git-send-email-eric.dong@intel.com> <734D49CCEBEEF84792F5B80ED585239D5BA913E9@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BA913E9@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 05:51:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, I think we can just base on DXE phase bits to prepare the communication buf= fer. I send new patches base on it. please check them. Thanks, Eric -----Original Message----- From: Ni, Ruiyu=20 Sent: Wednesday, October 11, 2017 11:25 AM To: Dong, Eric ; edk2-devel@lists.01.org Cc: Yao, Jiewen Subject: RE: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished e= vent to SmmCore. Eric, We may have 4 combinations for PEI DXE CPU architecture: 1. 32bit PEI + 32bit DXE: sizeof (UINTN) =3D=3D sizeof (UINT32) && NOT PcdD= xeIplSwitchToLongMode 2. 32bit PEI + 64bit DXE: sizeof (UINTN) =3D=3D sizeof (UINT32) && PcdDxeIp= lSwitchToLongMode 3. 64bit PEI + 32bit DXE: NA!!! 4. 64bit PEI + 64bit DXE: sizeof (UINTN) !=3D sizeof (UINT32) && NOT PcdDxe= IplSwitchToLongMode For #4, your code treats MessageLength as 4-byte, but actually it should be= 8-byte. So how about we just check PcdDxeIplSwitchToLongMode, when it's FALSE, size= of (MessageLength) equals to sizeof (UINTN). Otherwise, sizeof (MessageLength) equals to 8. So you only need to define: > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; And I recommend to change the structure name to X64_EFI_SMM_COMMUNICATE_HEA= DER or IA64_EFI_SMM_COMMUNICATE_HEADER. I am neutral using X64 or IA64, but don't = want to have EFI_ in the beginning. Thanks/Ray > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 10:23 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Yao, Jiewen > Subject: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished > event to SmmCore. >=20 > Driver will send S3 resume finished event to SmmCore through communicate > buffer after it signals EndOfPei event. >=20 > Cc: Ruiyu Ni > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 85 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 89 insertions(+) >=20 > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..8350eb9 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > @@ -28,6 +28,9 @@ > #include > #include > #include > +#include > + > +#include >=20 > #include > #include > @@ -151,6 +154,23 @@ typedef union { > UINT64 Uint64; > } PAGE_TABLE_1G_ENTRY; >=20 > +// > +// Define two type of smm communicate headers. > +// One for 32 bits PEI + 64 bits DXE, the other for 32 bits PEI + 32 bi= ts DXE > case. > +// > +typedef struct { > + > + EFI_GUID HeaderGuid; > + UINT32 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA32; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; > + > #pragma pack() >=20 > // > @@ -430,6 +450,65 @@ IsLongModeWakingVector ( } >=20 > /** > + Send EndOfS3Resume event to SmmCore through communication buffer > way. > + > + @retval EFI_SUCCESS Return send the event success. > +**/ > +EFI_STATUS > +SignalEndOfS3Resume ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi; > + UINTN CommSize; > + EFI_SMM_COMMUNICATE_HEADER_IA32 Header32; > + EFI_SMM_COMMUNICATE_HEADER_IA64 Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // Detect whether current is 32 bits PEI + 64 bits DXE case. > + // > + if ((sizeof(UINTN) =3D=3D sizeof(UINT32)) && (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer =3D &Header64; > + Header64.MessageLength =3D 0; > + CommSize =3D sizeof (EFI_SMM_COMMUNICATE_HEADER_IA64); > + } else { > + CommBuffer =3D &Header32; > + Header32.MessageLength =3D 0; > + CommSize =3D sizeof (EFI_SMM_COMMUNICATE_HEADER_IA32); > + } > + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); > + > + // > + // Get needed resource > + // > + Status =3D PeiServicesLocatePpi ( > + &gEfiPeiSmmCommunicationPpiGuid, > + 0, > + NULL, > + (VOID **)&SmmCommunicationPpi > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Send command > + // > + Status =3D SmmCommunicationPpi->Communicate ( > + SmmCommunicationPpi, > + (VOID *)CommBuffer, > + &CommSize > + ); > + ASSERT_EFI_ERROR (Status); > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status)); > + > + return Status; > +} > + > +/** > Jump to OS waking vector. > The function will install boot script done PPI, report S3 resume statu= s code, > and then jump to OS waking vector. >=20 > @@ -504,6 +583,12 @@ S3ResumeBootOs ( > ASSERT_EFI_ERROR (Status); >=20 > // > + // Signal EndOfS3Resume event. > + // > + Status =3D SignalEndOfS3Resume (); > + ASSERT_EFI_ERROR (Status); > + > + // > // report status code on S3 resume > // > REPORT_STATUS_CODE (EFI_PROGRESS_CODE, > EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); diff --git > a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > index d514523..943f114 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > @@ -85,6 +85,10 @@ > gPeiSmmAccessPpiGuid ## SOMETIMES_CONSUMES > gPeiPostScriptTablePpiGuid ## SOMETIMES_PRODUCES > gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES > + gEfiPeiSmmCommunicationPpiGuid ## SOMETIMES_CONSUMES > + > +[Protocols] > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_CONSUMES >=20 > [FeaturePcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## > CONSUMES > -- > 2.7.0.windows.1