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
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel