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.20; helo=mga02.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 D27AD222CF1BA for ; Wed, 10 Jan 2018 01:21:20 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 01:26:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,339,1511856000"; d="scan'208";a="192305079" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 10 Jan 2018 01:26:32 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 Jan 2018 01:26:31 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Wed, 10 Jan 2018 17:26:29 +0800 From: "Zeng, Star" To: krishnaLee , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [edk2] Communicate with soft-smi-handler with uefi-application question. Thread-Index: AQHTiebwLE0P6fhol0unJrefyGs1qKNs1Sew Date: Wed, 10 Jan 2018 09:26:28 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9F9E1C@shsmsx102.ccr.corp.intel.com> References: <31e5cb44.8179.160df068d3a.Coremail.sssky307@163.com> In-Reply-To: <31e5cb44.8179.160df068d3a.Coremail.sssky307@163.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: Communicate with soft-smi-handler with uefi-application question. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2018 09:21:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The trusted smm communication buffer needs to be allocated as EfiReservedMe= moryType, EfiACPIMemoryNVS, or EfiRuntimeServicesData before EndOfDxe. There is a generic smm communication buffer can be used if MdeModulePkg\Uni= versal\SmmCommunicationBufferDxe is included in dsc and fdf. You can refer https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Ap= plication/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c#L90 to know how it = be used. Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of kris= hnaLee Sent: Wednesday, January 10, 2018 3:44 PM To: edk2-devel@lists.01.org Subject: [edk2] Communicate with soft-smi-handler with uefi-application que= stion. Hi, I'm learning to write and register some soft-Smi-Handler in smm-mode; then= using QEMU to boot my ovmf.fd,run into uefi shell; then write uefi-applica= tion using EFI_SMM_COMMUNICATION_PROTOCOL to Communicate to my Smi-Handler,= but failed when run my uefi-application,the log show error. I don't know why,maybe I do not full understand uefi-smm,but how to communi= cate to my smi handler? //error-message [Security] 3rd party image[0] can be loaded after EndOfDxe: PciRoot(0x0)/Pc= i(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/\mytests= mm.efi. InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 65FC4A8 Load= ing driver at 0x000062B0000 EntryPoint=3D0x000062B10F5 mytestsmm.efi InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 65FCB10 Prot= ectUefiImageCommon - 0x65FC4A8 - 0x00000000062B0000 - 0x0000000000007000 InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 7700CFC InstallProtocolInterface: 4C8A2451-C207-405B-9694-99EA13251341 62B40B0 Loca= te EfiSmmCommunicationProtocol success SmmIsBufferOutsideSmmValid: Not in ValidCommunicationRegion: Buffer (0x7700= C94) - Length (0x2A), ASSERT [PiSmmCore] d:\edk2-vudk2017\MdePkg\Library\Sm= mMemLib\SmmMemLib.c(178): ((BOOLEAN)(0=3D=3D1)) //error-message-end //my register-smi-handler code: //edk2-vUDK2017\MdeModulePkg\Universal\LockBox\SmmLockBox\SmmLockBox.c EFI_STATUS EFIAPI MyTestSmmHandler ( IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL ) { DEBUG ((DEBUG_INFO, "My Test Smm Handler Enter\n")); DEBUG ((DEBUG_INFO, "My Test Smm Handler exit\n")); return EFI_SUCCESS; } EFI_STATUS EFIAPI SmmLockBoxEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) {... //Register My Test Smm handler Status =3D gSmst->SmiHandlerRegister ( MyTestSmmHandler, &gEfiMyTestSmmGuid, &DispatchHandle ); ASSERT_EFI_ERROR (Status); ... } //the uefi-application code EFI_STATUS EFIAPI UefiMain ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication; EFI_SMM_COMMUNICATE_HEAD= ER *SmmCommunicateHeader; UINT8 *buffer; UINTN bufferSize; bufferSize=3Dsizeof(EFI_SMM_COMMUNICATE_HEADER)*2; gBS->AllocatePool (EfiRuntimeServicesData,bufferSize,&buffer); if(buffer=3D=3DNULL) { Print(L"EFI_OUT_OF_RESOURCES, return\n"); return EFI_OUT_OF_RESOURCES; } SmmCommunicateHeader=3D(EFI_SMM_COMMUNICATE_HEADER*)buffer; CopyGuid(&SmmCommunicateHeader->HeaderGuid,&gEfiMyTestSmmGuid); SmmCommunicateHeader->MessageLength=3Dsizeof(EFI_SMM_COMMUNICATE_HEADER); Status =3D gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (V= OID **) &mSmmCommunication); if(Status=3D=3DEFI_SUCCESS) { Print(L"Locate EfiSmmCommunicationProtocol success\n"); }else { Print(L"Loc= ate EfiSmmCommunicationProtocol failed return\n"); return EFI_SUCCESS; } Status=3DmSmmCommunication->Communicate(mSmmCommunication,&buffer,&bufferSi= ze); if(Status=3D=3DEFI_SUCCESS) { Print(L"Communication success\n"); }else { Print(L"Communication failed\n"); return EFI_SUCCESS; } gBS->FreePool(buffer); return EFI_SUCCESS; } any help will be appreciated! by krishna _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel