From: "Zeng, Star" <star.zeng@intel.com>
To: krishnaLee <sssky307@163.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: Communicate with soft-smi-handler with uefi-application question.
Date: Wed, 10 Jan 2018 09:26:28 +0000 [thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9F9E1C@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <31e5cb44.8179.160df068d3a.Coremail.sssky307@163.com>
The trusted smm communication buffer needs to be allocated as EfiReservedMemoryType, EfiACPIMemoryNVS, or EfiRuntimeServicesData before EndOfDxe.
There is a generic smm communication buffer can be used if MdeModulePkg\Universal\SmmCommunicationBufferDxe is included in dsc and fdf.
You can refer https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Application/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 krishnaLee
Sent: Wednesday, January 10, 2018 3:44 PM
To: edk2-devel@lists.01.org
Subject: [edk2] Communicate with soft-smi-handler with uefi-application question.
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-application 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 communicate to my smi handler?
//error-message
[Security] 3rd party image[0] can be loaded after EndOfDxe: PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/\mytestsmm.efi.
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 65FC4A8 Loading driver at 0x000062B0000 EntryPoint=0x000062B10F5 mytestsmm.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 65FCB10 ProtectUefiImageCommon - 0x65FC4A8
- 0x00000000062B0000 - 0x0000000000007000
InstallProtocolInterface: 752F3136-4E16-4FDC-A22A-E5F46812F4CA 7700CFC
InstallProtocolInterface: 4C8A2451-C207-405B-9694-99EA13251341 62B40B0 Locate EfiSmmCommunicationProtocol success
SmmIsBufferOutsideSmmValid: Not in ValidCommunicationRegion: Buffer (0x7700C94) - Length (0x2A), ASSERT [PiSmmCore] d:\edk2-vudk2017\MdePkg\Library\SmmMemLib\SmmMemLib.c(178): ((BOOLEAN)(0==1)) //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 = 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_HEADER *SmmCommunicateHeader;
UINT8 *buffer;
UINTN bufferSize;
bufferSize=sizeof(EFI_SMM_COMMUNICATE_HEADER)*2;
gBS->AllocatePool (EfiRuntimeServicesData,bufferSize,&buffer);
if(buffer==NULL)
{
Print(L"EFI_OUT_OF_RESOURCES, return\n"); return EFI_OUT_OF_RESOURCES; }
SmmCommunicateHeader=(EFI_SMM_COMMUNICATE_HEADER*)buffer;
CopyGuid(&SmmCommunicateHeader->HeaderGuid,&gEfiMyTestSmmGuid);
SmmCommunicateHeader->MessageLength=sizeof(EFI_SMM_COMMUNICATE_HEADER);
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);
if(Status==EFI_SUCCESS)
{
Print(L"Locate EfiSmmCommunicationProtocol success\n"); }else { Print(L"Locate EfiSmmCommunicationProtocol failed return\n"); return EFI_SUCCESS; }
Status=mSmmCommunication->Communicate(mSmmCommunication,&buffer,&bufferSize);
if(Status==EFI_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
next prev parent reply other threads:[~2018-01-10 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 7:43 Communicate with soft-smi-handler with uefi-application question krishnaLee
2018-01-10 9:26 ` Zeng, Star [this message]
2018-01-11 0:38 ` krishnaLee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B9F9E1C@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox