Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [6.2.3]

### Fixed
- Linux: pick libmei 1.8.3 - empty kind fix
- Linux: return NOT_SUPPORTED on ENODATA
- Linux: use the right side of cancel pipe
- EFI: error out on wrong type
- EFI: add missed status to prints
- Windows: limit buffer size

### Removed
- drop conan support

## [6.2.2]

### Changed
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Details for each point and good commit message examples can be found on https://
- CMake: changes in the cmake build configuration.
- tests: changes in tests.
- samples: changes in samples.
- conan: changes in conan configuration.
- doc: changes in documentation.

### Sign your work
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.2
6.2.3
49 changes: 0 additions & 49 deletions conanfile.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/Windows/metee_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ TEESTATUS TEEAPI TeeRead(IN PTEEHANDLE handle, IN OUT void* buffer, IN size_t bu
goto Cleanup;
}

status = BeginOverlappedInternal(ReadOperation, handle, buffer, (ULONG)bufferSize, impl_handle->evt[METEE_WIN_EVT_READ]);
status = BeginOverlappedInternal(ReadOperation, handle, buffer, bufferSize, impl_handle->evt[METEE_WIN_EVT_READ]);
if (status) {
ERRPRINT(handle, "Error in BeginOverlappedInternal, error: %d\n", status);
impl_handle->state = METEE_CLIENT_STATE_FAILED;
Expand Down Expand Up @@ -422,7 +422,7 @@ TEESTATUS TEEAPI TeeWrite(IN PTEEHANDLE handle, IN const void* buffer, IN size_t
goto Cleanup;
}

status = BeginOverlappedInternal(WriteOperation, handle, (PVOID)buffer, (ULONG)bufferSize, impl_handle->evt[METEE_WIN_EVT_WRITE]);
status = BeginOverlappedInternal(WriteOperation, handle, (PVOID)buffer, bufferSize, impl_handle->evt[METEE_WIN_EVT_WRITE]);
if (status) {
ERRPRINT(handle, "Error in BeginOverlappedInternal, error: %d\n", status);
impl_handle->state = METEE_CLIENT_STATE_FAILED;
Expand Down
4 changes: 2 additions & 2 deletions src/Windows/metee_win.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2014-2025 Intel Corporation
* Copyright (C) 2014-2026 Intel Corporation
*/
#ifndef __TEELIBWIN_H
#define __TEELIBWIN_H
Expand Down Expand Up @@ -49,7 +49,7 @@ typedef enum _TEE_OPERATION
**********************************************************************/
TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation,
IN PTEEHANDLE handle, IN PVOID buffer,
IN ULONG bufferSize, OUT EVENTHANDLE evt);
IN size_t bufferSize, OUT EVENTHANDLE evt);
TEESTATUS EndOverlapped(IN PTEEHANDLE handle, IN EVENTHANDLE evt, IN DWORD milliseconds,
OUT OPTIONAL LPDWORD pNumberOfBytesTransferred);
TEESTATUS GetDevicePath(IN PTEEHANDLE handle, IN LPCGUID InterfaceGuid,
Expand Down
12 changes: 9 additions & 3 deletions src/Windows/metee_winhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CallbackPrintHelper(IN PTEEHANDLE handle, bool is_error, const char* args,
** TEE_INTERNAL_ERROR
*/
TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation, IN PTEEHANDLE handle,
IN PVOID buffer, IN ULONG bufferSize, OUT EVENTHANDLE evt)
IN PVOID buffer, IN size_t bufferSize, OUT EVENTHANDLE evt)
{
TEESTATUS status;
DWORD bytesTransferred= 0;
Expand All @@ -61,13 +61,19 @@ TEESTATUS BeginOverlappedInternal(IN TEE_OPERATION operation, IN PTEEHANDLE hand
goto Cleanup;
}

if (bufferSize > MAXDWORD) {
status = TEE_INVALID_PARAMETER;
ERRPRINT(handle, "Buffer size is too big: %zu\n", bufferSize);
goto Cleanup;
}

if (operation == ReadOperation) {
if (ReadFile(impl_handle->handle, buffer, bufferSize, &bytesTransferred, evt)) {
if (ReadFile(impl_handle->handle, buffer, (DWORD)bufferSize, &bytesTransferred, evt)) {
optSuccesed = TRUE;
}
}
else if (operation == WriteOperation) {
if (WriteFile(impl_handle->handle, buffer, bufferSize, &bytesTransferred, evt)) {
if (WriteFile(impl_handle->handle, buffer, (DWORD)bufferSize, &bytesTransferred, evt)) {
optSuccesed = TRUE;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/linux/mei.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ static inline int __mei_getkind(struct mei *me, const char *device, char *kind,
return -me->last_err;
}

if (len == 0) {
me->last_err = ENODATA;
close(fd);
return -me->last_err;
}

close(fd);
if ((size_t)len > *kind_size || !kind) {
me->last_err = ENOSPC;
Expand Down
9 changes: 5 additions & 4 deletions src/linux/metee_linux.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2014-2025 Intel Corporation
* Copyright (C) 2014-2026 Intel Corporation
*/
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -73,6 +73,7 @@ static inline TEESTATUS errno2status(ssize_t err)
case -ETIME : return TEE_TIMEOUT;
case -EACCES: return TEE_PERMISSION_DENIED;
case -EOPNOTSUPP: return TEE_NOTSUPPORTED;
case -ENODATA: return TEE_NOTSUPPORTED;
case -ECANCELED: return TEE_UNABLE_TO_COMPLETE_OPERATION;
case -ENOSPC: return TEE_INSUFFICIENT_BUFFER;
default : return TEE_INTERNAL_ERROR;
Expand Down Expand Up @@ -327,7 +328,7 @@ TEESTATUS TEEAPI TeeRead(IN PTEEHANDLE handle, IN OUT void *buffer, IN size_t bu

ltimeout = (timeout) ? (int)timeout : -1;

rc = __mei_select(me, intl->cancel_pipe[1], true, ltimeout);
rc = __mei_select(me, intl->cancel_pipe[0], true, ltimeout);
if (rc) {
status = errno2status(rc);
ERRPRINT(handle, "select failed with status %zd %s\n",
Expand Down Expand Up @@ -390,7 +391,7 @@ TEESTATUS TEEAPI TeeWrite(IN PTEEHANDLE handle, IN const void *buffer, IN size_t

ltimeout = (timeout) ? (int)timeout : -1;

rc = __mei_select(me, intl->cancel_pipe[1], false, ltimeout);
rc = __mei_select(me, intl->cancel_pipe[0], false, ltimeout);
if (rc) {
status = errno2status(rc);
ERRPRINT(handle, "select failed with status %zd %s\n",
Expand Down Expand Up @@ -724,4 +725,4 @@ TEESTATUS TEEAPI TeeGetKind(IN PTEEHANDLE handle, IN OUT char *kind, IN OUT size
End:
FUNC_EXIT(handle, status);
return status;
}
}
41 changes: 21 additions & 20 deletions src/uefi/heci_efi.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2024-2025 Intel Corporation
* Copyright (C) 2024-2026 Intel Corporation
*/

#include <Uefi.h>
Expand Down Expand Up @@ -318,13 +318,13 @@ EfiTeeHeciUninitialize(
status = heciSendMsg(Handle, (UINT32 *)&disconnectMsg, (UINT32)sizeof(disconnectMsg), (UINT8)BIOS_FIXED_HOST_ADDR, (UINT8)HECI_HBM_MSG_ADDR);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "####Failed to send HBM_CLIENT_DISCONNECT_REQUEST. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "####Failed to send HBM_CLIENT_DISCONNECT_REQUEST. Status: %llu\n", (unsigned long long)status);
goto End;
}
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&disconnectMsgReply, sizeof(disconnectMsgReply), &msgReplyLen);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "####Failed with ReadMsg, Status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "####Failed with ReadMsg, Status: %llu.\n", (unsigned long long)status);
goto End;
}
DBGPRINT(Handle->TeeHandle, "#### disconnectMsgReply Command %02X , Status: %02X.\n", disconnectMsgReply.Command, disconnectMsgReply.Status);
Expand Down Expand Up @@ -382,7 +382,7 @@ heciFwToHostFlowControl(
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&flowCtrlMsg, sizeof(HBM_FLOW_CONTROL), &msgLen);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "#####Flow control: wait for FW failed with status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "#####Flow control: wait for FW failed with status: %llu.\n", (unsigned long long)status);
goto End;
}

Expand Down Expand Up @@ -427,7 +427,7 @@ heciHostToSecFlowControl(
status = heciSendMsg(Handle, (UINT32 *)&flowCtrlMsg, sizeof(flowCtrlMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "#####Flow control: send to FW failed with status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "#####Flow control: send to FW failed with status: %llu.\n", (unsigned long long)status);
goto End;
}

Expand Down Expand Up @@ -464,7 +464,7 @@ HeciDeviceEnumerateClients(
status = heciReset(Handle);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Failed to send HECI reset. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "Failed to send HECI reset. Status: %llu\n", (unsigned long long)status);
status = EFI_DEVICE_ERROR;
goto End;
}
Expand All @@ -488,7 +488,7 @@ HeciDeviceEnumerateClients(
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&enumMsgReply, sizeof(HBM_HOST_ENUMERATION_RESPONSE), &msgReplyLen);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %llu\n", (unsigned long long)status);
if (EFI_TIMEOUT == status)
{
continue;
Expand All @@ -501,7 +501,7 @@ HeciDeviceEnumerateClients(

if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "Failed to read HBM_HOST_ENUMERATION_REQUEST. Status: %llu.\n", (unsigned long long)status);
goto End;
}
DBGPRINT(Handle->TeeHandle, "HBM_HOST_ENUMERATION_RESPONSE: [Command: %d]\n", enumMsgReply.Command);
Expand Down Expand Up @@ -530,15 +530,15 @@ HeciDeviceEnumerateClients(
status = heciSendMsg(Handle, (UINT32 *)&propMsg, sizeof(propMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Failed to send HBM_CLIENT_PROP_MSG. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "Failed to send HBM_CLIENT_PROP_MSG. Status: %llu\n", (unsigned long long)status);
goto End;
}

SetMem(&propMsgReply, sizeof(HBM_CLIENT_PROP_MSG_REPLY), 0x0);
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&propMsgReply, sizeof(HBM_CLIENT_PROP_MSG_REPLY), &msgReplyLen);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "heciReadMsg failed to read HBM_CLIENT_PROP_MSG response. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "heciReadMsg failed to read HBM_CLIENT_PROP_MSG response. Status: %llu\n", (unsigned long long)status);
goto End;
}

Expand Down Expand Up @@ -620,7 +620,7 @@ EfiTeeHeciConnectClient(
status = HeciDeviceEnumerateClients(Handle, lib);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Could not HeciDeviceEnumerateClients, Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "Could not HeciDeviceEnumerateClients, Status: %llu\n", (unsigned long long)status);
status = EFI_DEVICE_ERROR;
goto End;
}
Expand Down Expand Up @@ -664,7 +664,7 @@ EfiTeeHeciConnectClient(
}
if (host_client_id == TEE_MAX_FW_CLIENTS)
{
DBGPRINT(Handle->TeeHandle, "Max client count reached\n", status);
DBGPRINT(Handle->TeeHandle, "Max client count reached\n");
status = EFI_DEVICE_ERROR;
goto End;
}
Expand All @@ -690,14 +690,14 @@ EfiTeeHeciConnectClient(
status = heciSendMsg(Handle, (UINT32 *)&connectMsg, sizeof(connectMsg), BIOS_FIXED_HOST_ADDR, HECI_HBM_MSG_ADDR);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Connect Send failed with status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "Connect Send failed with status: %llu.\n", (unsigned long long)status);
goto End;
}

status = heciReadMsg(Handle, BLOCKING, (UINT32 *)&connectMsgReply, sizeof(HBM_CLIENT_CONNECT_RESPONSE), &msgReplyLen);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Connect Recv failed with status: %d.\n", status);
DBGPRINT(Handle->TeeHandle, "Connect Recv failed with status: %llu.\n", (unsigned long long)status);
goto End;
}

Expand Down Expand Up @@ -799,7 +799,7 @@ EfiTeeHeciSendMessage(
status = heciHostToSecFlowControl(Handle, client, fwAddress);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "heciHostToSecFlowControl Failed. Status: %d", status);
DBGPRINT(Handle->TeeHandle, "heciHostToSecFlowControl Failed. Status: %llu", (unsigned long long)status);
goto End;
}

Expand All @@ -811,7 +811,7 @@ EfiTeeHeciSendMessage(
status = heciSendMsg(Handle, (UINT32 *)buffer, bufferLength, hostAddress, fwAddress);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "SendMessage: failed to send message. Status: %d.", status);
DBGPRINT(Handle->TeeHandle, "SendMessage: failed to send message. Status: %llu.", (unsigned long long)status);
goto End;
}
*BytesWritten = bufferLength;
Expand Down Expand Up @@ -882,7 +882,8 @@ EfiTeeHeciReceiveMessage(
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)Buffer, BufferSize, &bytes_read);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "\nReadMsg: first reply read failed. bytesRead: %d. Status: %d\n", bytes_read, status);
DBGPRINT(Handle->TeeHandle, "\nReadMsg: first reply read failed. bytesRead: %d. Status: %llu\n",
bytes_read, (unsigned long long)status);
goto End;
}

Expand All @@ -899,7 +900,7 @@ EfiTeeHeciReceiveMessage(
status = heciReadMsg(Handle, BLOCKING, (UINT32 *)Buffer, BufferSize, &bytes_read);
if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "heciReadMsg. Status: %d\n");
DBGPRINT(Handle->TeeHandle, "heciReadMsg. Status: %llu\n", (unsigned long long)status);
if (EFI_TIMEOUT == status)
{
DBGPRINT(Handle->TeeHandle, "Detected EFI_TIMEOUT.\n");
Expand All @@ -911,7 +912,7 @@ EfiTeeHeciReceiveMessage(

if (EFI_ERROR(status))
{
DBGPRINT(Handle->TeeHandle, "Retry failed. Status: %d\n", status);
DBGPRINT(Handle->TeeHandle, "Retry failed. Status: %llu\n", (unsigned long long)status);
goto End;
}
}
Expand All @@ -930,7 +931,7 @@ EfiTeeHeciReceiveMessage(
{
EFIPRINT(Handle->TeeHandle, "FixedAddress: %d\n", client->properties.FixedAddress);
status = heciFwToHostFlowControl(Handle, client);
DBGPRINT(Handle->TeeHandle, "heciFwToHostFlowControl. Status: %d\n");
DBGPRINT(Handle->TeeHandle, "heciFwToHostFlowControl. Status: %llu\n", (unsigned long long)status);
goto End;
}

Expand Down
Loading
Loading