Date
1 - 2 of 2
Communication example from OS to firmware using SmmCommunicationCommunicate() ?
mzktsn@...
Hello,
I am interested into asking a question if anyone knows how an application in the Runtime OS, can transfer some data (an array of characters for example) into the Smm side, by making use of the SmmCommunicationCommunicate() function? Reading the Intel's manual there is the possibility to use outb on a specific IO port and create an SMI which is going to switch mode to SMM, but i was curious of how the data can be shared back and forth f.e. Thanks in advance |
|
The low-level infrastructure to implement SMM communication is described in https://github.com/tianocore-docs/Docs/raw/master/White_Papers/A_Tour_Beyond_BIOS_Secure_SMM_Communication.pdf for EDKII
toggle quoted message
Show quoted text
The direct access to the SMM comm buffer is typically not exposed to applications in the UEFI OS's, though, in a generic fashion. During pre-OS you can locate the EFI_MM_COMMUNICATION2_PROTOCOL interface to invoke SMM and keep a pointer to this API into runtime in order to perform the SMM communications from a kernel-mode entity at OS runtime. One trick we have seen people do in the past is create a UEFI variable w/ a pointer a runtime interface and then: During pre-OS Locate EFI_MM_COMMUNICATION2_PROTOCOL Create variable Y = address of EFI_MM_COMMUNICATION2_PROTOCOL During OS runtime Locate Variable Y (see OS specific API below) Invoke EFI_SMM_COMMUNICATION2_PROTOCOL from function pointer in Y (while in ring0 since uefi runtime API's are not supported in OS userland directly) There used to exist the table https://uefi.org/specs/UEFI/2.10/Apx_O_UEFI_ACPI_Data_Table.html?highlight=smm#uefi-acpi-data-table to expose this SMM communication interface during OS runtime but per industry feedback: " NOTE: The use of the SMM Communication ACPI table is deprecated in UEFI spec. 2.7. This is due to the lack of a use case for inter-mode communication by non-firmware agents with SMM code and support for initiating this form of communication in common OSes." On some x64 systems UEFI variables are implemented in SMM https://github.com/tianocore-docs/Docs/raw/master/White_Papers/A_Tour_Beyond_BIOS_Implementing_UEFI_Authenticated_Variables_in_SMM_with_EDKII_V2.pdf and you can access variables via sysfs or efivars https://docs.kernel.org/filesystems/efivarfs.html in Linux and https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfirmwareenvironmentvariableexa in windows userland and windows kernel land https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-exgetfirmwareenvironmentvariable. This is another, albeit ad hoc way, to pass info from OS user land into smm. The flow of the latter using variables as a way to talk to an SMM handler would be OS application set variable X with interesting information to share w/ an SMM handler <the set variable action will activate SMM flow> SMM handler would use the EDKII-specific interface https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Include/Protocol/SmmVariable.h to read variable X with OS application info And you have the similar option to return info from the SMM handler to the OS application via the get variable interface. Vincent -----Original Message-----
From: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of mzktsn@... Sent: Friday, September 23, 2022 3:58 AM To: discuss@edk2.groups.io Subject: [edk2-discuss] Communication example from OS to firmware using SmmCommunicationCommunicate() ? Hello, I am interested into asking a question if anyone knows how an application in the Runtime OS, can transfer some data (an array of characters for example) into the Smm side, by making use of the SmmCommunicationCommunicate() function? Reading the Intel's manual there is the possibility to use outb on a specific IO port and create an SMI which is going to switch mode to SMM, but i was curious of how the data can be shared back and forth f.e. Thanks in advance |
|