mei.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. .. SPDX-License-Identifier: GPL-2.0
  2. Introduction
  3. ============
  4. The Intel Management Engine (Intel ME) is an isolated and protected computing
  5. resource (Co-processor) residing inside certain Intel chipsets. The Intel ME
  6. provides support for computer/IT management and security features.
  7. The actual feature set depends on the Intel chipset SKU.
  8. The Intel Management Engine Interface (Intel MEI, previously known as HECI)
  9. is the interface between the Host and Intel ME. This interface is exposed
  10. to the host as a PCI device, actually multiple PCI devices might be exposed.
  11. The Intel MEI Driver is in charge of the communication channel between
  12. a host application and the Intel ME features.
  13. Each Intel ME feature, or Intel ME Client is addressed by a unique GUID and
  14. each client has its own protocol. The protocol is message-based with a
  15. header and payload up to maximal number of bytes advertised by the client,
  16. upon connection.
  17. Intel MEI Driver
  18. ================
  19. The driver exposes a character device with device nodes /dev/meiX.
  20. An application maintains communication with an Intel ME feature while
  21. /dev/meiX is open. The binding to a specific feature is performed by calling
  22. :c:macro:`MEI_CONNECT_CLIENT_IOCTL`, which passes the desired GUID.
  23. The number of instances of an Intel ME feature that can be opened
  24. at the same time depends on the Intel ME feature, but most of the
  25. features allow only a single instance.
  26. The driver is transparent to data that are passed between firmware feature
  27. and host application.
  28. Because some of the Intel ME features can change the system
  29. configuration, the driver by default allows only a privileged
  30. user to access it.
  31. The session is terminated calling :c:expr:`close(fd)`.
  32. A code snippet for an application communicating with Intel AMTHI client:
  33. In order to support virtualization or sandboxing a trusted supervisor
  34. can use :c:macro:`MEI_CONNECT_CLIENT_IOCTL_VTAG` to create
  35. virtual channels with an Intel ME feature. Not all features support
  36. virtual channels such client with answer EOPNOTSUPP.
  37. .. code-block:: C
  38. struct mei_connect_client_data data;
  39. fd = open(MEI_DEVICE);
  40. data.d.in_client_uuid = AMTHI_GUID;
  41. ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &data);
  42. printf("Ver=%d, MaxLen=%ld\n",
  43. data.d.in_client_uuid.protocol_version,
  44. data.d.in_client_uuid.max_msg_length);
  45. [...]
  46. write(fd, amthi_req_data, amthi_req_data_len);
  47. [...]
  48. read(fd, &amthi_res_data, amthi_res_data_len);
  49. [...]
  50. close(fd);
  51. User space API
  52. IOCTLs:
  53. =======
  54. The Intel MEI Driver supports the following IOCTL commands:
  55. IOCTL_MEI_CONNECT_CLIENT
  56. -------------------------
  57. Connect to firmware Feature/Client.
  58. .. code-block:: none
  59. Usage:
  60. struct mei_connect_client_data client_data;
  61. ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &client_data);
  62. Inputs:
  63. struct mei_connect_client_data - contain the following
  64. Input field:
  65. in_client_uuid - GUID of the FW Feature that needs
  66. to connect to.
  67. Outputs:
  68. out_client_properties - Client Properties: MTU and Protocol Version.
  69. Error returns:
  70. ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
  71. EINVAL Wrong IOCTL Number
  72. ENODEV Device or Connection is not initialized or ready.
  73. ENOMEM Unable to allocate memory to client internal data.
  74. EFAULT Fatal Error (e.g. Unable to access user input data)
  75. EBUSY Connection Already Open
  76. :Note:
  77. max_msg_length (MTU) in client properties describes the maximum
  78. data that can be sent or received. (e.g. if MTU=2K, can send
  79. requests up to bytes 2k and received responses up to 2k bytes).
  80. IOCTL_MEI_CONNECT_CLIENT_VTAG:
  81. ------------------------------
  82. .. code-block:: none
  83. Usage:
  84. struct mei_connect_client_data_vtag client_data_vtag;
  85. ioctl(fd, IOCTL_MEI_CONNECT_CLIENT_VTAG, &client_data_vtag);
  86. Inputs:
  87. struct mei_connect_client_data_vtag - contain the following
  88. Input field:
  89. in_client_uuid - GUID of the FW Feature that needs
  90. to connect to.
  91. vtag - virtual tag [1, 255]
  92. Outputs:
  93. out_client_properties - Client Properties: MTU and Protocol Version.
  94. Error returns:
  95. ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
  96. EINVAL Wrong IOCTL Number or tag == 0
  97. ENODEV Device or Connection is not initialized or ready.
  98. ENOMEM Unable to allocate memory to client internal data.
  99. EFAULT Fatal Error (e.g. Unable to access user input data)
  100. EBUSY Connection Already Open
  101. EOPNOTSUPP Vtag is not supported
  102. IOCTL_MEI_NOTIFY_SET
  103. ---------------------
  104. Enable or disable event notifications.
  105. .. code-block:: none
  106. Usage:
  107. uint32_t enable;
  108. ioctl(fd, IOCTL_MEI_NOTIFY_SET, &enable);
  109. uint32_t enable = 1;
  110. or
  111. uint32_t enable[disable] = 0;
  112. Error returns:
  113. EINVAL Wrong IOCTL Number
  114. ENODEV Device is not initialized or the client not connected
  115. ENOMEM Unable to allocate memory to client internal data.
  116. EFAULT Fatal Error (e.g. Unable to access user input data)
  117. EOPNOTSUPP if the device doesn't support the feature
  118. :Note:
  119. The client must be connected in order to enable notification events
  120. IOCTL_MEI_NOTIFY_GET
  121. --------------------
  122. Retrieve event
  123. .. code-block:: none
  124. Usage:
  125. uint32_t event;
  126. ioctl(fd, IOCTL_MEI_NOTIFY_GET, &event);
  127. Outputs:
  128. 1 - if an event is pending
  129. 0 - if there is no even pending
  130. Error returns:
  131. EINVAL Wrong IOCTL Number
  132. ENODEV Device is not initialized or the client not connected
  133. ENOMEM Unable to allocate memory to client internal data.
  134. EFAULT Fatal Error (e.g. Unable to access user input data)
  135. EOPNOTSUPP if the device doesn't support the feature
  136. :Note:
  137. The client must be connected and event notification has to be enabled
  138. in order to receive an event
  139. Supported Chipsets
  140. ==================
  141. 82X38/X48 Express and newer
  142. linux-mei@linux.intel.com