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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [4.3.0]

### Fixed
- Windows: process access denied on open
- UEFI: Add driver logic for fixed clients

### Added
- Windows: add resource
- cmake: add 32 bit release preset
- add getters for maxMsgLen and prtocolVer

## [4.2.1]

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ option(CONSOLE_OUTPUT "Push debug and error output to console (instead of syslog

include(GNUInstallDirs)

set(LICENSE Apache)
include(version.cmake)

if(WIN32)
include(win32.cmake)
else(WIN32)
include(linux.cmake)
endif(WIN32)

set(LICENSE Apache)
include(version.cmake)

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/metee.h)
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${TEE_VERSION_STRING})
set_target_properties(
Expand Down
15 changes: 15 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
"BUILD_SHARED_LIBS": "NO"
}
},
{
"name": "Release32",
"displayName": "Windows x86 Release",
"description": "Build x86 Release, VS2019",
"inherits": "base32",
"binaryDir": "${sourceDir}/Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "Release64",
"displayName": "Windows x86-64 Release",
Expand Down Expand Up @@ -107,6 +117,11 @@
"configurePreset": "Release32Static",
"configuration": "Release"
},
{
"name": "Release32",
"configurePreset": "Release32",
"configuration": "Release"
},
{
"name": "Release64",
"configurePreset": "Release64",
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.1
4.3.0
16 changes: 16 additions & 0 deletions include/metee.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,22 @@ uint32_t TEEAPI TeeGetLogLevel(IN const PTEEHANDLE handle);
*/
TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback log_callback);

/*! Retrieve client maximum message length (MTU)
*
* \param handle The handle of the session.
* \return client maximum message length.
* If client never connected, will return zero.
*/
uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle);

/*! Retrieve client protocol version
*
* \param handle The handle of the session.
* \return client protocol version.
* If client never connected, will return zero.
*/
uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 8 additions & 2 deletions samples/metee_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ int main(int argc, char* argv[])
goto out;
}

if (TeeGetMaxMsgLen(&handle) == 0)
{
fprintf(stderr, "Client reported zero MTU. Aborting.\n");
goto out;
}

/* Write */
req.header.data = 0; /* Reset */
req.header.GroupId = 0xFF; /* MKHI */
Expand All @@ -115,14 +121,14 @@ int main(int argc, char* argv[])
}

/* Read */
read_buf = (uint8_t*)malloc(handle.maxMsgLen);
read_buf = (uint8_t*)malloc(TeeGetMaxMsgLen(&handle));
if (!read_buf) {
fprintf(stderr, "malloc failed\n");
status = TEE_INTERNAL_ERROR;
goto out;
}

status = TeeRead(&handle, read_buf, handle.maxMsgLen, &written, MKHI_TIMEOUT);
status = TeeRead(&handle, read_buf, TeeGetMaxMsgLen(&handle), &written, MKHI_TIMEOUT);
if (!TEE_IS_SUCCESS(status)) {
fprintf(stderr, "TeeWrite failed with status = %u\n", status);
goto out;
Expand Down
7 changes: 6 additions & 1 deletion samples/metee_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ static int work(struct params *p)
if (status != TEE_SUCCESS)
goto out;

rsz = cl.maxMsgLen;
rsz = TeeGetMaxMsgLen(&cl);
if (rsz == 0)
{
fprintf(stderr, "client reproted zero MTU.\n");
goto out;
}
buf = (unsigned char *)malloc(rsz);
if (buf == NULL)
goto out;
Expand Down
10 changes: 8 additions & 2 deletions samples/metee_gsc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*/
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -158,7 +158,13 @@ static uint32_t mk_host_if_call(struct mk_host_if *acmd,
struct gsc_fwu_heci_response *msg_hdr;
int count = 0;

in_buf_sz = (unsigned int)acmd->mei_cl.maxMsgLen;
in_buf_sz = TeeGetMaxMsgLen(&acmd->mei_cl);
if (in_buf_sz == 0)
{
if (acmd->verbose)
fprintf(stderr, "mkhif: client reproted zero MTU.\n");
return GSC_FWU_STATUS_FAILURE;
}
*read_buf = (uint8_t *)malloc(in_buf_sz);
if (*read_buf == NULL)
return GSC_FWU_STATUS_FAILURE;
Expand Down
10 changes: 8 additions & 2 deletions samples/metee_mkhi.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2012-2023 Intel Corporation
* Copyright (C) 2012-2024 Intel Corporation
*/
#include <stdarg.h>
#include <stdio.h>
Expand Down Expand Up @@ -235,7 +235,13 @@ static uint32_t mk_host_if_call(struct mk_host_if *acmd,
struct mk_host_if_msg *msg_hdr;
int count = 0;

in_buf_sz = (unsigned int)acmd->mei_cl.maxMsgLen;
in_buf_sz = TeeGetMaxMsgLen(&acmd->mei_cl);
if (in_buf_sz == 0)
{
if (acmd->verbose)
fprintf(stderr, "mkhif: client reproted zero MTU.\n");
return MKHI_STATUS_INTERNAL_ERROR;
}
*read_buf = (uint8_t *)malloc(in_buf_sz);
if (*read_buf == NULL)
return MKHI_STATUS_SDK_RESOURCES;
Expand Down
102 changes: 102 additions & 0 deletions src/Windows/metee.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2024 Intel Corporation
*/
// Microsoft Visual C++ generated resource script.
//

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <Windows.h>

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION @TEE_VERSION_COMM@
PRODUCTVERSION @TEE_VERSION_COMM@
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Intel Corporation"
VALUE "FileDescription", "Intel(R) CSME/GSC HECI Interface Library"
VALUE "FileVersion", "@TEE_VERSION_STRING@"
VALUE "InternalName", "MeTee"
VALUE "LegalCopyright", "Copyright (c) 2014-2024, Intel Corporation."
VALUE "OriginalFilename", "metee.dll"
VALUE "ProductName", "Intel(R) CSME/GSC HECI Interface Library"
VALUE "ProductVersion", "@TEE_VERSION_STRING@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

31 changes: 28 additions & 3 deletions src/Windows/metee_win.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2014-2023 Intel Corporation
* Copyright (C) 2014-2024 Intel Corporation
*/
#include <assert.h>
#include <windows.h>
Expand All @@ -27,10 +27,19 @@ static TEESTATUS __CreateFile(PTEEHANDLE handle, const char *devicePath, PHANDLE
if (*deviceHandle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
ERRPRINT(handle, "Error in CreateFile, error: %lu\n", err);
if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
switch (err)
{
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
status = TEE_DEVICE_NOT_FOUND;
else
break;
case ERROR_ACCESS_DENIED:
status = TEE_PERMISSION_DENIED;
break;
default:
status = TEE_DEVICE_NOT_READY;
break;
}
}
else {
status = TEE_SUCCESS;
Expand Down Expand Up @@ -667,3 +676,19 @@ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback lo
FUNC_EXIT(handle, status);
return status;
}

uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle)
{
if (NULL == handle) {
return 0;
}
return (uint32_t)handle->maxMsgLen;
}

uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle)
{
if (NULL == handle) {
return 0;
}
return handle->protcolVer;
}
16 changes: 16 additions & 0 deletions src/linux/metee_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,19 @@ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback lo
FUNC_EXIT(handle, status);
return status;
}

uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle)
{
if (!handle) {
return 0;
}
return (uint32_t)handle->maxMsgLen;
}

uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle)
{
if (!handle) {
return 0;
}
return handle->protcolVer;
}
Loading
Loading