From: krishnaLee <sssky307@163.com>
To: edk2-devel@lists.01.org
Subject: Communicate with soft-smi-handler with uefi-application question.
Date: Wed, 10 Jan 2018 15:43:56 +0800 (CST) [thread overview]
Message-ID: <31e5cb44.8179.160df068d3a.Coremail.sssky307@163.com> (raw)
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
next reply other threads:[~2018-01-10 7:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 7:43 krishnaLee [this message]
2018-01-10 9:26 ` Communicate with soft-smi-handler with uefi-application question Zeng, Star
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=31e5cb44.8179.160df068d3a.Coremail.sssky307@163.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