Management Engine Interface
Single-page view · as markdown
Intel(R) Management Engine Interface (Intel(R) MEI)
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
Copyright © 2019 Intel Corporation
Table of Contents
HDCP:
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
ME FW as a security engine provides the capability for setting up HDCP2.2 protocol negotiation between the Intel graphics device and an HDC2.2 sink.
ME FW prepares HDCP2.2 negotiation parameters, signs and encrypts them according the HDCP 2.2 spec. The Intel graphics sends the created blob to the HDCP2.2 sink.
Similarly, the HDCP2.2 sink's response is transferred to ME FW for decryption and verification.
Once all the steps of HDCP2.2 negotiation are completed, upon request ME FW will configure the port as authenticated and supply the HDCP encryption keys to Intel graphics hardware.
mei_hdcp driver #
The mei_hdcp driver acts as a translation layer between HDCP 2.2 protocol implementer (I915) and ME FW by translating HDCP2.2 negotiation messages to ME FW command payloads and vice versa.
mei_hdcp api #
mei_hdcp_initiate_session() #
int Initiate a Wired HDCP2.2 Tx Session in ME FW
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_ake_init *ake_data: AKE_Init msg output.
Return
0 on Success, <0 on Failure.
mei_hdcp_verify_receiver_cert_prepare_km() #
int Verify the Receiver Certificate AKE_Send_Cert and prepare AKE_Stored_Km/AKE_No_Stored_Km
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_ake_send_cert *rx_cert: AKE_Send_Cert for verificationbool *km_stored: Pairing status flag outputstruct hdcp2_ake_no_stored_km *ek_pub_km: AKE_Stored_Km/AKE_No_Stored_Km output msgsize_t *msg_sz: size of AKE_XXXXX_Km output msg
Return
0 on Success, <0 on Failure
mei_hdcp_verify_hprime() #
int Verify AKE_Send_H_prime at ME FW.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_ake_send_hprime *rx_hprime: AKE_Send_H_prime msg for ME FW verification
Return
0 on Success, <0 on Failure
mei_hdcp_store_pairing_info() #
int Store pairing info received at ME FW
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_ake_send_pairing_info *pairing_info: AKE_Send_Pairing_Info msg input to ME FW
Return
0 on Success, <0 on Failure
mei_hdcp_initiate_locality_check() #
int Prepare LC_Init
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_lc_init *lc_init_data: LC_Init msg output
Return
0 on Success, <0 on Failure
mei_hdcp_verify_lprime() #
int Verify lprime.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_lc_send_lprime *rx_lprime: LC_Send_L_prime msg for ME FW verification
Return
0 on Success, <0 on Failure
mei_hdcp_get_session_key() #
int Prepare SKE_Send_Eks.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_ske_send_eks *ske_data: SKE_Send_Eks msg output from ME FW.
Return
0 on Success, <0 on Failure
mei_hdcp_repeater_check_flow_prepare_ack() #
int Validate the Downstream topology and prepare rep_ack.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_rep_send_receiverid_list *rep_topology: Receiver ID List to be validatedstruct hdcp2_rep_send_ack *rep_send_ack: repeater ack from ME FW.
Return
0 on Success, <0 on Failure
mei_hdcp_verify_mprime() #
int Verify mprime.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp datastruct hdcp2_rep_stream_ready *stream_ready: RepeaterAuth_Stream_Ready msg for ME FW verification.
Return
0 on Success, <0 on Failure
mei_hdcp_enable_authentication() #
int Mark a port as authenticated through ME FW
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp data
Return
0 on Success, <0 on Failure
mei_hdcp_close_session() #
int Close the Wired HDCP Tx session of ME FW per port. This also disables the authenticated state of the port.
Parameters
struct device *dev: device corresponding to the mei_cl_devicestruct hdcp_port_data *data: Intel HW specific hdcp data
Return
0 on Success, <0 on Failure
mei_hdcp_component_match() #
int compare function for matching mei hdcp.
Parameters
struct device *dev: master deviceint subcomponent: subcomponent to match (I915_COMPONENT_HDCP)void *data: compare data (mei hdcp device)
Description
The function checks if the driver is i915, the subcomponent is HDCP and the grand parent of hdcp and the parent of i915 are the same PCH device.
Return
- 1 - if components match
- 0 - otherwise
Intel(R) Active Management Technology (Intel AMT)
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
Prominent usage of the Intel ME Interface is to communicate with Intel(R) Active Management Technology (Intel AMT) implemented in firmware running on the Intel ME.
Intel AMT provides the ability to manage a host remotely out-of-band (OOB) even when the operating system running on the host processor has crashed or is in a sleep state.
-
Some examples of Intel AMT usage are:
-
Monitoring hardware state and platform components
-
Remote power off/on (useful for green computing or overnight IT maintenance)
-
OS updates
-
Storage of useful platform information such as software assets
-
Built-in hardware KVM
-
Selective network isolation of Ethernet and IP protocol flows based on policies set by a remote management console
-
IDE device redirection from remote management console
-
Intel AMT (OOB) communication is based on SOAP (deprecated starting with Release 6.0) over HTTP/S or WS-Management protocol over HTTP/S that are received from a remote management console application.
For more information about Intel AMT: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm
Intel AMT Applications #
Intel Local Management Service (Intel LMS)
Applications running locally on the platform communicate with Intel AMT Release 2.0 and later releases in the same way that network applications do via SOAP over HTTP (deprecated starting with Release 6.0) or with WS-Management over SOAP over HTTP. This means that some Intel AMT features can be accessed from a local application using the same network interface as a remote application communicating with Intel AMT over the network.
When a local application sends a message addressed to the local Intel AMT host name, the Intel LMS, which listens for traffic directed to the host name, intercepts the message and routes it to the Intel MEI. For more information: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm Under "About Intel AMT" => "Local Access"
For downloading Intel LMS: https://github.com/intel/lms
The Intel LMS opens a connection using the Intel MEI driver to the Intel LMS firmware feature using a defined GUID and then communicates with the feature using a protocol called Intel AMT Port Forwarding Protocol (Intel APF protocol). The protocol is used to maintain multiple sessions with Intel AMT from a single application.
See the protocol specification in the Intel AMT Software Development Kit (SDK) https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm Under "SDK Resources" => "Intel(R) vPro(TM) Gateway (MPS)" => "Information for Intel(R) vPro(TM) Gateway Developers" => "Description of the Intel AMT Port Forwarding (APF) Protocol"
Intel AMT Remote configuration using a Local Agent
A Local Agent enables IT personnel to configure Intel AMT out-of-the-box without requiring installing additional data to enable setup. The remote configuration process may involve an ISV-developed remote configuration agent that runs on the host. For more information: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm Under "Setup and Configuration of Intel AMT" => "SDK Tools Supporting Setup and Configuration" => "Using the Local Agent Sample"
Intel AMT OS Health Watchdog #
The Intel AMT Watchdog is an OS Health (Hang/Crash) watchdog. Whenever the OS hangs or crashes, Intel AMT will send an event to any subscriber to this event. This mechanism means that IT knows when a platform crashes even when there is a hard failure on the host.
-
The Intel AMT Watchdog is composed of two parts:
-
Firmware feature - receives the heartbeats and sends an event when the heartbeats stop.
-
Intel MEI iAMT watchdog driver - connects to the watchdog feature, configures the watchdog and sends the heartbeats.
-
The Intel iAMT watchdog MEI driver uses the kernel watchdog API to configure the Intel AMT Watchdog and to send heartbeats to it. The default timeout of the watchdog is 120 seconds.
If the Intel AMT is not enabled in the firmware then the watchdog client won't enumerate on the me client bus and watchdog devices won't be exposed.
Intel(R) Management Engine (ME) Client bus API
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
Rationale #
The MEI character device is useful for dedicated applications to send and receive data to the many FW appliance found in Intel's ME from the user space. However, for some of the ME functionalities it makes sense to leverage existing software stack and expose them through existing kernel subsystems.
In order to plug seamlessly into the kernel device driver model we add kernel virtual bus abstraction on top of the MEI driver. This allows implementing Linux kernel drivers for the various MEI features as a stand alone entities found in their respective subsystem. Existing device drivers can even potentially be re-used by adding an MEI CL bus layer to the existing code.
MEI CL bus API #
A driver implementation for an MEI Client is very similar to any other existing bus based device drivers. The driver registers itself as an MEI CL bus driver through the struct mei_cl_driver structure defined in include/linux/mei_cl_bus.c
;
The mei_cl_device_id structure defined in include/linux/mod_devicetable.h allows a driver to bind itself against a device name.
;
To actually register a driver on the ME Client bus one must call the mei_cl_add_driver() API. This is typically called at module initialization time.
Once the driver is registered and bound to the device, a driver will typically try to do some I/O on this bus and this should be done through the mei_cl_send() and mei_cl_recv() functions. More detailed information is in API: section.
In order for a driver to be notified about pending traffic or event, the driver should register a callback via mei_cl_devev_register_rx_cb() and mei_cldev_register_notify_cb() function respectively.
API: #
mei_cldev_send_vtag() #
ssize_t me device send with vtag (write)
Parameters
struct mei_cl_device *cldev: me client deviceconst u8 *buf: buffer to sendsize_t length: buffer lengthu8 vtag: virtual tag
Return
- written size in bytes
- < 0 on error
mei_cldev_send_vtag_timeout() #
ssize_t me device send with vtag and timeout (write)
Parameters
struct mei_cl_device *cldev: me client deviceconst u8 *buf: buffer to sendsize_t length: buffer lengthu8 vtag: virtual tagunsigned long timeout: send timeout in milliseconds, 0 for infinite timeout
Return
- written size in bytes
- < 0 on error
mei_cldev_recv_vtag() #
ssize_t client receive with vtag (read)
Parameters
struct mei_cl_device *cldev: me client deviceu8 *buf: buffer to receivesize_t length: buffer lengthu8 *vtag: virtual tag
Return
- read size in bytes
- < 0 on error
mei_cldev_recv_timeout() #
ssize_t client receive with timeout (read)
Parameters
struct mei_cl_device *cldev: me client deviceu8 *buf: buffer to receivesize_t length: buffer lengthunsigned long timeout: send timeout in milliseconds, 0 for infinite timeout
Return
- read size in bytes
- < 0 on error
mei_cldev_recv_vtag_timeout() #
ssize_t client receive with vtag (read)
Parameters
struct mei_cl_device *cldev: me client deviceu8 *buf: buffer to receivesize_t length: buffer lengthu8 *vtag: virtual tagunsigned long timeout: recv timeout in milliseconds, 0 for infinite timeout
Return
- read size in bytes
- < 0 on error
mei_cldev_send() #
ssize_t me device send (write)
Parameters
struct mei_cl_device *cldev: me client deviceconst u8 *buf: buffer to sendsize_t length: buffer length
Return
- written size in bytes
- < 0 on error
mei_cldev_send_timeout() #
ssize_t me device send with timeout (write)
Parameters
struct mei_cl_device *cldev: me client deviceconst u8 *buf: buffer to sendsize_t length: buffer lengthunsigned long timeout: send timeout in milliseconds, 0 for infinite timeout
Return
- written size in bytes
- < 0 on error
mei_cldev_recv() #
ssize_t client receive (read)
Parameters
struct mei_cl_device *cldev: me client deviceu8 *buf: buffer to receivesize_t length: buffer length
Return
read size in bytes of < 0 on error
mei_cldev_register_rx_cb() #
int register Rx event callback
Parameters
struct mei_cl_device *cldev: me client devicesmei_cldev_cb_t rx_cb: callback function
Return
0 on success -EALREADY if an callback is already registered <0 on other errors
mei_cldev_register_notif_cb() #
int register FW notification event callback
Parameters
struct mei_cl_device *cldev: me client devicesmei_cldev_cb_t notif_cb: callback function
Return
0 on success -EALREADY if an callback is already registered <0 on other errors
mei_cldev_get_drvdata() #
void * driver data getter
Parameters
const struct mei_cl_device *cldev: mei client device
Return
driver private data
mei_cldev_set_drvdata() #
void driver data setter
Parameters
struct mei_cl_device *cldev: mei client devicevoid *data: data to store
mei_cldev_ver() #
u8 return protocol version of the underlying me client
Parameters
const struct mei_cl_device *cldev: mei client device
Return
me client protocol version
mei_cldev_mtu() #
size_t max message that client can send and receive
Parameters
const struct mei_cl_device *cldev: mei client device
Return
mtu or 0 if client is not connected
mei_cldev_enabled() #
bool check whether the device is enabled
Parameters
const struct mei_cl_device *cldev: mei client device
Return
true if me client is initialized and connected
mei_cldev_enable() #
int enable me client device create connection with me client
Parameters
struct mei_cl_device *cldev: me client device
Return
0 on success and < 0 on error
mei_cldev_disable() #
int disable me client device disconnect form the me client
Parameters
struct mei_cl_device *cldev: me client device
Return
0 on success and < 0 on error
mei_cldev_send_gsc_command() #
ssize_t sends a gsc command, by sending a gsl mei message to gsc and receiving reply from gsc
Parameters
struct mei_cl_device *cldev: me client deviceu8 client_id: client id to send the command tou32 fence_id: fence id to send the command tostruct scatterlist *sg_in: scatter gather list containing addresses for rx message buffersize_t total_in_len: total length of data in 'in' sg, can be less than the sum of buffers sizesstruct scatterlist *sg_out: scatter gather list containing addresses for tx message buffer
Return
- written size in bytes
- < 0 on error
Example #
As a theoretical example let's pretend the ME comes with a "contact" NFC IP. The driver init and exit routines for this device would look like:
static struct mei_cl_device_id contact_mei_cl_tbl = ;
;
static struct mei_cl_driver contact_driver = ;
static int
static void __exit
;
;
And the driver's simplified probe routine would look like that:
int
In the probe routine the driver first enable the MEI device and then registers an rx handler which is as close as it can get to registering a threaded IRQ handler. The handler implementation will typically call mei_cldev_recv() and then process received data.
static void
MEI Client Bus Drivers #
Introduction
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
Peios: Interface availability and resource limits do not grant native access. Peios applies descriptor/handle checks, its sysfs write gate and mapped privilege checks where applicable. Read inherited privileged/unprivileged terminology with Peios kernel behaviour.
Introduction #
The Intel Management Engine (Intel ME) is an isolated and protected computing resource (Co-processor) residing inside certain Intel chipsets. The Intel ME provides support for computer/IT management and security features. The actual feature set depends on the Intel chipset SKU.
The Intel Management Engine Interface (Intel MEI, previously known as HECI) is the interface between the Host and Intel ME. This interface is exposed to the host as a PCI device, actually multiple PCI devices might be exposed. The Intel MEI Driver is in charge of the communication channel between a host application and the Intel ME features.
Each Intel ME feature, or Intel ME Client is addressed by a unique GUID and each client has its own protocol. The protocol is message-based with a header and payload up to maximal number of bytes advertised by the client, upon connection.
Intel MEI Driver #
The driver exposes a character device with device nodes /dev/meiX.
An application maintains communication with an Intel ME feature while /dev/meiX is open. The binding to a specific feature is performed by calling MEI_CONNECT_CLIENT_IOCTL, which passes the desired GUID. The number of instances of an Intel ME feature that can be opened at the same time depends on the Intel ME feature, but most of the features allow only a single instance.
The driver is transparent to data that are passed between firmware feature and host application.
Because some of the Intel ME features can change the system configuration, the driver by default allows only a privileged user to access it.
The session is terminated calling close(fd).
A code snippet for an application communicating with Intel AMTHI client:
In order to support virtualization or sandboxing a trusted supervisor can use MEI_CONNECT_CLIENT_IOCTL_VTAG to create virtual channels with an Intel ME feature. Not all features support virtual channels such client with answer EOPNOTSUPP.
struct mei_connect_client_data data;
fd = ;
data.d.in_client_uuid = AMTHI_GUID;
;
;
;
;
;
User space API
IOCTLs: #
The Intel MEI Driver supports the following IOCTL commands:
IOCTL_MEI_CONNECT_CLIENT #
Connect to firmware Feature/Client.
Usage:
struct mei_connect_client_data client_data;
ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &client_data);
Inputs:
struct mei_connect_client_data - contain the following
Input field:
in_client_uuid - GUID of the FW Feature that needs
to connect to.
Outputs:
out_client_properties - Client Properties: MTU and Protocol Version.
Error returns:
ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
EINVAL Wrong IOCTL Number
ENODEV Device or Connection is not initialized or ready.
ENOMEM Unable to allocate memory to client internal data.
EFAULT Fatal Error (e.g. Unable to access user input data)
EBUSY Connection Already Open
Note: max_msg_length (MTU) in client properties describes the maximum data that can be sent or received. (e.g. if MTU=2K, can send requests up to bytes 2k and received responses up to 2k bytes).
IOCTL_MEI_CONNECT_CLIENT_VTAG: #
Usage:
struct mei_connect_client_data_vtag client_data_vtag;
ioctl(fd, IOCTL_MEI_CONNECT_CLIENT_VTAG, &client_data_vtag);
Inputs:
struct mei_connect_client_data_vtag - contain the following
Input field:
in_client_uuid - GUID of the FW Feature that needs
to connect to.
vtag - virtual tag [1, 255]
Outputs:
out_client_properties - Client Properties: MTU and Protocol Version.
Error returns:
ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
EINVAL Wrong IOCTL Number or tag == 0
ENODEV Device or Connection is not initialized or ready.
ENOMEM Unable to allocate memory to client internal data.
EFAULT Fatal Error (e.g. Unable to access user input data)
EBUSY Connection Already Open
EOPNOTSUPP Vtag is not supported
IOCTL_MEI_NOTIFY_SET #
Enable or disable event notifications.
Usage:
uint32_t enable;
ioctl(fd, IOCTL_MEI_NOTIFY_SET, &enable);
uint32_t enable = 1;
or
uint32_t enable[disable] = 0;
Error returns:
EINVAL Wrong IOCTL Number
ENODEV Device is not initialized or the client not connected
ENOMEM Unable to allocate memory to client internal data.
EFAULT Fatal Error (e.g. Unable to access user input data)
EOPNOTSUPP if the device doesn't support the feature
Note: The client must be connected in order to enable notification events
IOCTL_MEI_NOTIFY_GET #
Retrieve event
Usage:
uint32_t event;
ioctl(fd, IOCTL_MEI_NOTIFY_GET, &event);
Outputs:
1 - if an event is pending
0 - if there is no even pending
Error returns:
EINVAL Wrong IOCTL Number
ENODEV Device is not initialized or the client not connected
ENOMEM Unable to allocate memory to client internal data.
EFAULT Fatal Error (e.g. Unable to access user input data)
EOPNOTSUPP if the device doesn't support the feature
Note: The client must be connected and event notification has to be enabled in order to receive an event
Supported Chipsets #
82X38/X48 Express and newer
MEI NFC
Peios Kernel / Hardware and drivers / Driver development / Management Engine Interface
Some Intel 8 and 9 Series chipsets support NFC devices connected behind the Intel Management Engine controller. MEI client bus exposes the NFC chips as NFC phy devices and enables binding with Microread and NXP PN544 NFC device driver from the Linux NFC subsystem.
flowchart TB n0(["mei/bus(nfc)"]) n1(["me fw (nfc)"]) n2(["drivers/nfc/mei_phy"]) n3(["drivers/nfc/microread/mei"]) n4(["drivers/nfc/pn544/mei"]) n5(["net/nfc"]) n6(["neard"]) n0 --> n1 n2 --> n0 n3 --> n0 n3 --> n2 n4 --> n0 n4 --> n2 n5 --> n3 n5 --> n4 n6 --> n5
MEI NFC Stack