Skip to content

Commit

Permalink
libteec: Move OP-TEE defined fields into an imp struct
Browse files Browse the repository at this point in the history
GlobalPlatform TEE Client API Specification v1.0 specifies that
the structs TEEC_Context, TEEC_Session, TEEC_SharedMemory,
and TEEC_Operation shall have a user defined struct named imp.
In OP-TEE the struct is not there and instead the user defined
fields are declared directly in the top structs.
This commit introduces the imp struct to better support using
different implementations. The imp fields now represent the
implementation defined parts of the structs that was
previously declared directly in the top struct. All previously
available parameters are preserved in the imp struct.
Adding the missing imp struct to the structs in OP-TEE is an
ABI breakage which requires a version major update of libteec
as explained by Jerome Forissier.

Link: OP-TEE#348
Reported-by: Tom Hebb <[email protected]>
Signed-off-by: Julianus Larson <[email protected]>

Fixed spacing
  • Loading branch information
JLLinaro committed Oct 27, 2023
1 parent acb0885 commit b3c0606
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 106 deletions.
2 changes: 1 addition & 1 deletion libteec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(libteec
VERSION 1.0.0
VERSION 2.0.0
LANGUAGES C)

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion libteec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ all: libteec
################################################################################
# Teec configuration
################################################################################
MAJOR_VERSION := 1
MAJOR_VERSION := 2
MINOR_VERSION := 0
PATCH_VERSION := 0
LIB_NAME := libteec.so
Expand Down
44 changes: 27 additions & 17 deletions libteec/include/tee_client_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ typedef uint32_t TEEC_Result;
*/
typedef struct {
/* Implementation defined */
int fd;
bool reg_mem;
bool memref_null;
struct {
int fd;
bool reg_mem;
bool memref_null;
} imp;
} TEEC_Context;

/**
Expand Down Expand Up @@ -293,16 +295,18 @@ typedef struct {
size_t size;
uint32_t flags;
/*
* Implementation-Defined
* Implementation defined
*/
int id;
size_t alloced_size;
void *shadow_buffer;
int registered_fd;
union {
bool dummy;
uint8_t flags;
} internal;
struct {
int id;
size_t alloced_size;
void *shadow_buffer;
int registered_fd;
union {
bool dummy;
uint8_t flags;
} internal;
} imp;
} TEEC_SharedMemory;

/**
Expand Down Expand Up @@ -384,8 +388,10 @@ typedef union {
*/
typedef struct {
/* Implementation defined */
TEEC_Context *ctx;
uint32_t session_id;
struct{
TEEC_Context *ctx;
uint32_t session_id;
} imp;
} TEEC_Session;

/**
Expand All @@ -398,16 +404,20 @@ typedef struct {
* create the correct flags.
* 0 means TEEC_NONE is passed for all params.
* @param params Array of parameters of type TEEC_Parameter.
* @param session Internal pointer to the last session used by
* @param imp Implementation defined parameter. Here it is a struct
* containing one parameter: session. session is an
* internal pointer to the last session used by
* TEEC_InvokeCommand with this operation.
*
*/
typedef struct {
uint32_t started;
uint32_t paramTypes;
TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT];
/* Implementation-Defined */
TEEC_Session *session;
/* Implementation defined */
struct {
TEEC_Session *session;
} imp;
} TEEC_Operation;

/**
Expand Down
Loading

0 comments on commit b3c0606

Please sign in to comment.