Tomas Winkler | 7e527e1 | 2019-06-03 12:14:00 +0300 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 2 | |
| 3 | Introduction |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 4 | ============ |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 5 | |
Justin P. Mattock | 5f9092f3 | 2012-03-12 07:18:09 -0700 | [diff] [blame] | 6 | The Intel Management Engine (Intel ME) is an isolated and protected computing |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 7 | resource (Co-processor) residing inside certain Intel chipsets. The Intel ME |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 8 | provides support for computer/IT management and security features. |
| 9 | The actual feature set depends on the Intel chipset SKU. |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 10 | |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 11 | The Intel Management Engine Interface (Intel MEI, previously known as HECI) |
| 12 | is the interface between the Host and Intel ME. This interface is exposed |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 13 | to the host as a PCI device, actually multiple PCI devices might be exposed. |
| 14 | The Intel MEI Driver is in charge of the communication channel between |
| 15 | a host application and the Intel ME features. |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 16 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 17 | Each Intel ME feature, or Intel ME Client is addressed by a unique GUID and |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 18 | each client has its own protocol. The protocol is message-based with a |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 19 | header and payload up to maximal number of bytes advertised by the client, |
| 20 | upon connection. |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 21 | |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 22 | Intel MEI Driver |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 23 | ================ |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 24 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 25 | The driver exposes a character device with device nodes /dev/meiX. |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 26 | |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 27 | An application maintains communication with an Intel ME feature while |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 28 | /dev/meiX is open. The binding to a specific feature is performed by calling |
| 29 | :c:macro:`MEI_CONNECT_CLIENT_IOCTL`, which passes the desired GUID. |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 30 | The number of instances of an Intel ME feature that can be opened |
| 31 | at the same time depends on the Intel ME feature, but most of the |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 32 | features allow only a single instance. |
| 33 | |
Tomas Winkler | f6a4e49 | 2012-05-29 16:39:09 +0300 | [diff] [blame] | 34 | The driver is transparent to data that are passed between firmware feature |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 35 | and host application. |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 36 | |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 37 | Because some of the Intel ME features can change the system |
| 38 | configuration, the driver by default allows only a privileged |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 39 | user to access it. |
| 40 | |
Mauro Carvalho Chehab | ccf1227 | 2020-09-29 12:43:40 +0200 | [diff] [blame] | 41 | The session is terminated calling :c:expr:`close(fd)`. |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 42 | |
Tomas Winkler | f6a4e49 | 2012-05-29 16:39:09 +0300 | [diff] [blame] | 43 | A code snippet for an application communicating with Intel AMTHI client: |
| 44 | |
Tomas Winkler | 2257b74 | 2020-08-18 14:51:46 +0300 | [diff] [blame] | 45 | In order to support virtualization or sandboxing a trusted supervisor |
| 46 | can use :c:macro:`MEI_CONNECT_CLIENT_IOCTL_VTAG` to create |
| 47 | virtual channels with an Intel ME feature. Not all features support |
| 48 | virtual channels such client with answer EOPNOTSUPP. |
| 49 | |
Tomas Winkler | 7e527e1 | 2019-06-03 12:14:00 +0300 | [diff] [blame] | 50 | .. code-block:: C |
| 51 | |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 52 | struct mei_connect_client_data data; |
| 53 | fd = open(MEI_DEVICE); |
| 54 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 55 | data.d.in_client_uuid = AMTHI_GUID; |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 56 | |
| 57 | ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &data); |
| 58 | |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 59 | printf("Ver=%d, MaxLen=%ld\n", |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 60 | data.d.in_client_uuid.protocol_version, |
| 61 | data.d.in_client_uuid.max_msg_length); |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 62 | |
| 63 | [...] |
| 64 | |
| 65 | write(fd, amthi_req_data, amthi_req_data_len); |
| 66 | |
| 67 | [...] |
| 68 | |
| 69 | read(fd, &amthi_res_data, amthi_res_data_len); |
| 70 | |
| 71 | [...] |
| 72 | close(fd); |
| 73 | |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 74 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 75 | User space API |
| 76 | |
| 77 | IOCTLs: |
| 78 | ======= |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 79 | |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 80 | The Intel MEI Driver supports the following IOCTL commands: |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 81 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 82 | IOCTL_MEI_CONNECT_CLIENT |
| 83 | ------------------------- |
| 84 | Connect to firmware Feature/Client. |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 85 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 86 | .. code-block:: none |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 87 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 88 | Usage: |
| 89 | |
| 90 | struct mei_connect_client_data client_data; |
| 91 | |
| 92 | ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &client_data); |
| 93 | |
| 94 | Inputs: |
| 95 | |
| 96 | struct mei_connect_client_data - contain the following |
| 97 | Input field: |
| 98 | |
| 99 | in_client_uuid - GUID of the FW Feature that needs |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 100 | to connect to. |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 101 | Outputs: |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 102 | out_client_properties - Client Properties: MTU and Protocol Version. |
| 103 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 104 | Error returns: |
| 105 | |
| 106 | ENOTTY No such client (i.e. wrong GUID) or connection is not allowed. |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 107 | EINVAL Wrong IOCTL Number |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 108 | ENODEV Device or Connection is not initialized or ready. |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 109 | ENOMEM Unable to allocate memory to client internal data. |
| 110 | EFAULT Fatal Error (e.g. Unable to access user input data) |
| 111 | EBUSY Connection Already Open |
| 112 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 113 | :Note: |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 114 | max_msg_length (MTU) in client properties describes the maximum |
| 115 | data that can be sent or received. (e.g. if MTU=2K, can send |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 116 | requests up to bytes 2k and received responses up to 2k bytes). |
Oren Weil | 463ac7f | 2011-12-06 23:25:18 +0200 | [diff] [blame] | 117 | |
Tomas Winkler | 2257b74 | 2020-08-18 14:51:46 +0300 | [diff] [blame] | 118 | IOCTL_MEI_CONNECT_CLIENT_VTAG: |
| 119 | ------------------------------ |
| 120 | |
| 121 | .. code-block:: none |
| 122 | |
| 123 | Usage: |
| 124 | |
| 125 | struct mei_connect_client_data_vtag client_data_vtag; |
| 126 | |
| 127 | ioctl(fd, IOCTL_MEI_CONNECT_CLIENT_VTAG, &client_data_vtag); |
| 128 | |
| 129 | Inputs: |
| 130 | |
| 131 | struct mei_connect_client_data_vtag - contain the following |
| 132 | Input field: |
| 133 | |
| 134 | in_client_uuid - GUID of the FW Feature that needs |
| 135 | to connect to. |
| 136 | vtag - virtual tag [1, 255] |
| 137 | |
| 138 | Outputs: |
| 139 | out_client_properties - Client Properties: MTU and Protocol Version. |
| 140 | |
| 141 | Error returns: |
| 142 | |
| 143 | ENOTTY No such client (i.e. wrong GUID) or connection is not allowed. |
| 144 | EINVAL Wrong IOCTL Number or tag == 0 |
| 145 | ENODEV Device or Connection is not initialized or ready. |
| 146 | ENOMEM Unable to allocate memory to client internal data. |
| 147 | EFAULT Fatal Error (e.g. Unable to access user input data) |
| 148 | EBUSY Connection Already Open |
| 149 | EOPNOTSUPP Vtag is not supported |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 150 | |
| 151 | IOCTL_MEI_NOTIFY_SET |
| 152 | --------------------- |
| 153 | Enable or disable event notifications. |
| 154 | |
| 155 | |
| 156 | .. code-block:: none |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 157 | |
| 158 | Usage: |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 159 | |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 160 | uint32_t enable; |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 161 | |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 162 | ioctl(fd, IOCTL_MEI_NOTIFY_SET, &enable); |
| 163 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 164 | |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 165 | uint32_t enable = 1; |
| 166 | or |
| 167 | uint32_t enable[disable] = 0; |
| 168 | |
| 169 | Error returns: |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 170 | |
| 171 | |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 172 | EINVAL Wrong IOCTL Number |
| 173 | ENODEV Device is not initialized or the client not connected |
| 174 | ENOMEM Unable to allocate memory to client internal data. |
| 175 | EFAULT Fatal Error (e.g. Unable to access user input data) |
| 176 | EOPNOTSUPP if the device doesn't support the feature |
| 177 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 178 | :Note: |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 179 | The client must be connected in order to enable notification events |
| 180 | |
| 181 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 182 | IOCTL_MEI_NOTIFY_GET |
| 183 | -------------------- |
| 184 | Retrieve event |
| 185 | |
| 186 | .. code-block:: none |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 187 | |
| 188 | Usage: |
| 189 | uint32_t event; |
| 190 | ioctl(fd, IOCTL_MEI_NOTIFY_GET, &event); |
| 191 | |
| 192 | Outputs: |
| 193 | 1 - if an event is pending |
| 194 | 0 - if there is no even pending |
| 195 | |
| 196 | Error returns: |
| 197 | EINVAL Wrong IOCTL Number |
| 198 | ENODEV Device is not initialized or the client not connected |
| 199 | ENOMEM Unable to allocate memory to client internal data. |
| 200 | EFAULT Fatal Error (e.g. Unable to access user input data) |
| 201 | EOPNOTSUPP if the device doesn't support the feature |
| 202 | |
Tomas Winkler | d0a1780 | 2019-06-06 16:31:08 +0300 | [diff] [blame] | 203 | :Note: |
Tomas Winkler | 3c7c846 | 2015-07-26 09:54:20 +0300 | [diff] [blame] | 204 | The client must be connected and event notification has to be enabled |
| 205 | in order to receive an event |
| 206 | |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 207 | |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 208 | |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 209 | Supported Chipsets |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 210 | ================== |
Tomas Winkler | 7e527e1 | 2019-06-03 12:14:00 +0300 | [diff] [blame] | 211 | 82X38/X48 Express and newer |
Julian Brost | cfba678 | 2015-01-12 00:58:06 +0100 | [diff] [blame] | 212 | |
Oren Weil | 6624fc2 | 2011-05-15 13:43:39 +0300 | [diff] [blame] | 213 | linux-mei@linux.intel.com |