From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 BEFF821E11D25 for ; Thu, 12 Oct 2017 01:11:15 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2017 01:14:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,365,1503385200"; d="scan'208";a="1229927337" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 12 Oct 2017 01:14:45 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 12 Oct 2017 01:14:45 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 12 Oct 2017 01:14:44 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Thu, 12 Oct 2017 16:14:34 +0800 From: "Dong, Eric" To: Laszlo Ersek CC: "Ni, Ruiyu" , "edk2-devel@lists.01.org" , "Yao, Jiewen" Thread-Topic: [edk2] [Patch v3 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. Thread-Index: AQHTQmocvz+/m32USUCWgf5campVsKLfVY6AgACItSA= Date: Thu, 12 Oct 2017 08:14:34 +0000 Message-ID: References: <1507710130-3044-1-git-send-email-eric.dong@intel.com> <1507710130-3044-3-git-send-email-eric.dong@intel.com> <8d678707-fb07-0326-acfd-878bb7e8c5d6@redhat.com> In-Reply-To: <8d678707-fb07-0326-acfd-878bb7e8c5d6@redhat.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 v3 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: Thu, 12 Oct 2017 08:11:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Laszlo, Sorry for this patch break OVMF. Platform without this Ppi is not what we e= xpected before. So we just add ASSERT here.=20 I will send a patch ASAP to fix this ASSERT case. Also we will provide an= other patch later to handle the platform without this Ppi case. Thanks, Eric -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Lasz= lo Ersek Sent: Thursday, October 12, 2017 4:01 PM To: Dong, Eric Cc: Ni, Ruiyu ; edk2-devel@lists.01.org; Yao, Jiewen Subject: Re: [edk2] [Patch v3 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume = finished event to SmmCore. Hi, I'm sorry that I couldn't comment on this patch in time. However, I must observe that version 1 of the patch, http://mid.mail-archive.com/1507688554-10264-3-git-send-email-eric.dong@int= el.com was sent out at 04:22 AM on 11 Oct, in my time zone; and version 3 of the p= atch was committed at 04:17 AM on 12 Oct in my time zone. That's not a lot of time for reviewers to comment -- I was very busy with o= ther stuff yesterday. I even set up an auto-reply about that, asking for a = bit of patience. Of course the auto-reply didn't help, because I wasn't CC'd on the patch in= the first place; despite my earlier request to be CC'd on all SMM- and/or = S3-related patches. So, after this introduction: On 10/11/17 10:22, Eric Dong wrote: > Driver will send S3 resume finished event to SmmCore through=20 > communicate buffer after it signals EndOfPei event. >=20 > V2 Changes: > 1. Change structures name to avoid they start with EFI_. > 2. Base on DXE phase bits to provide communication buffer, current=20 > implement check both PEI and DXE phase. >=20 > V3 Changes: > 1. Change structure name for better understanding. > 2. Enhance communication buffer calculate logic to more accurate. >=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 | 87 ++++++++++++++++= ++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 91 insertions(+) >=20 > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c=20 > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..c2171cb 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,22 @@ 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]; > +} SMM_COMMUNICATE_HEADER_32; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} SMM_COMMUNICATE_HEADER_64; > + > #pragma pack() > =20 > // > @@ -430,6 +449,68 @@ 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; > + SMM_COMMUNICATE_HEADER_32 Header32; > + SMM_COMMUNICATE_HEADER_64 Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // This buffer consumed in DXE phase, so base on DXE mode to prepare c= ommunicate buffer. > + // Detect whether DXE is 64 bits mode. > + // if (sizeof(UINTN) =3D=3D sizeof(UINT64), PEI already 64 bits, assum= e DXE also 64 bits. > + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch to = 64 bits. > + // > + if ((sizeof(UINTN) =3D=3D sizeof(UINT64)) || (FeaturePcdGet (PcdDxeIpl= SwitchToLongMode))) { > + CommBuffer =3D &Header64; > + Header64.MessageLength =3D 0; > + CommSize =3D OFFSET_OF (SMM_COMMUNICATE_HEADER_64, Data); } else { > + CommBuffer =3D &Header32; > + Header32.MessageLength =3D 0; > + CommSize =3D OFFSET_OF (SMM_COMMUNICATE_HEADER_32, Data); } =20 > + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); > + > + // > + // Get needed resource > + // > + Status =3D PeiServicesLocatePpi ( > + &gEfiPeiSmmCommunicationPpiGuid, > + 0, > + NULL, > + (VOID **)&SmmCommunicationPpi > + ); > + ASSERT_EFI_ERROR (Status); This patch breaks S3 resume with OVMF+SMM. OVMF does not have or install an= EFI_PEI_SMM_COMMUNICATION_PPI. We discussed this ~2 years ago, when SMM wa= s being added to KVM, QEMU, and OVMF. OVMF would have needed EFI_PEI_SMM_COMMUNICATION_PPI only for SmmLockBoxPei= Lib. But we agreed that SmmLockBoxPeiLib would work without this PPI; exact= ly the same as if the PPI existed, but Communicate() returned EFI_NOT_START= ED. Namely, if RestoreLockBox() failed to locate EFI_PEI_SMM_COMMUNICATION_PPI,= then InternalRestoreLockBoxFromSmram() would be called instead, which only= needed PEI_SMM_ACCESS_PPI. And OVMF would provide that, so everything woul= d work fine. Please see the following edk2 commits: https://github.com/tianocore/edk2/commit/bd3afeb1d62c https://github.com/tianocore/edk2/commit/9d560947f6d3 Eric, can you please modify SignalEndOfS3Resume() as follows: - locate EFI_PEI_SMM_COMMUNICATION_PPI as first action, - if it is not found, return EFI_NOT_FOUND gracefully, - in S3ResumeBootOs(), simply log the return value, and proceed. Currently, during S3 resume (with SMM), I get > SignalEndOfS3Resume - Enter > ASSERT_EFI_ERROR (Status =3D Not Found) > ASSERT UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c(496): !EFI_ERROR (Status) Thanks, Laszlo > + > + // > + // 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 +585,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 |=20 > EFI_SW_PEI_PC_OS_WAKE); diff --git=20 > a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf=20 > 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 ## CO= NSUMES >=20 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel