Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libteec: Move OP-TEE defined fields into an imp struct #349

Conversation

JLLinaro
Copy link
Contributor

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.

Link: #348
Reported-by: Tom Hebb [email protected]

@JLLinaro
Copy link
Contributor Author

The automatic tests fail but that has been solved in the following pull request OP-TEE/optee_test#684

@jforissier
Copy link
Contributor

This LGTM, but as mentioned in #348, it changes the layout of TEEC_SharedMemory and therefore is an ABI breakage. So the libteec version should be bumped from 1.0.0 to 2.0.0.

@github-actions
Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@github-actions
Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@jenswi-linaro
Copy link
Contributor

@JLLinaro would you mind updating this PR so we can merge it?

@JLLinaro
Copy link
Contributor Author

@jenswi-linaro version is now updated to 2.0.0

@jforissier
Copy link
Contributor

We need MAJOR_VERSION := 2 in libteec/Makefile, too.

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acked-by: Etienne Carriere <[email protected]> for commit
"libteec: Move OP-TEE defined fields into an imp struct"
(with indentation issue fixed)

bool dummy;
uint8_t flags;
} internal;
} imp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation

@jforissier
Copy link
Contributor

Please squash the second commit into the first one (and keep subject "libteec: Move OP-TEE defined fields into an imp struct").
With that:
Acked-by: Jerome Forissier <[email protected]>

@JLLinaro JLLinaro force-pushed the fix_imp_part_of_types_in_tee_client_api branch from dbe8282 to c004dbb Compare October 27, 2023 13:16
@jforissier
Copy link
Contributor

There is a conflict, would you please rebase onto master, and also add the Acked-by: tags from Etienne and me?

@JLLinaro JLLinaro force-pushed the fix_imp_part_of_types_in_tee_client_api branch from c004dbb to b3c0606 Compare October 27, 2023 14:09
@@ -384,8 +388,10 @@ typedef union {
*/
typedef struct {
/* Implementation defined */
TEEC_Context *ctx;
uint32_t session_id;
struct{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a space ( ), between struct and {.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JLLinaro comment not addressed

@jforissier
Copy link
Contributor

Ping @JLLinaro

Comment on lines 305 to 307
union {
bool dummy;
uint8_t flags;
} internal;
Copy link
Contributor

@vincent-mailhol vincent-mailhol Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the dummy field still needed following this change? dummy was introduced in 4f3d4cb not to break the ABI. Here we are breaking it anyway, so while at it, I suggest some clean up:

Suggested change
union {
bool dummy;
uint8_t flags;
} internal;
uint32_t flags;

N.B.: If there is a wish to keep more flag bits for future use, then just declare flags as uint32_t (the structure will be padded anyway, so you will not make it any bigger).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. uint32_t flags; LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JLLinaro comment not addressed

Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Dec 30, 2023
@github-actions github-actions bot closed this Jan 4, 2024
@jenswi-linaro jenswi-linaro reopened this Jan 4, 2024
@jforissier
Copy link
Contributor

@JLLinaro any chance this could make it into the next release? (-rc1 is in 3 days).

On the other hand, I am now wondering if this is a good idea. Who cares about this? Sure it is in the spec, but what difference does it make? Apps are not supposed to manipulate the imp field anyways. And changing it now will have impacts on downstream users (version change).

@github-actions github-actions bot removed the Stale label Jan 10, 2024
@jenswi-linaro
Copy link
Contributor

The answer to your question is in #348

@jforissier
Copy link
Contributor

jforissier commented Jan 10, 2024

The answer to your question is in #348

Ah, yes. It would be nice to mention in the commit description that the imp struct makes it easier to create a binding for Rust.

Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Feb 10, 2024
@jenswi-linaro
Copy link
Contributor

I think we need to explain to @JLLinaro that it's going to cost him a beer each time github reminds us that it's not done yet. :-)

Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Mar 14, 2024
@github-actions github-actions bot closed this Mar 19, 2024
@jforissier jforissier reopened this Mar 28, 2024
@JLLinaro JLLinaro force-pushed the fix_imp_part_of_types_in_tee_client_api branch 3 times, most recently from 6e9f710 to 7d2763f Compare March 28, 2024 10:58
Comment on lines 305 to 307
union {
uint32_t flags;
} internal;
Copy link
Contributor

@jforissier jforissier Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union should not be needed, just make this uint32_t flags;.

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.
The updated version of the imp structure makes it easier to
create a binding for Rust.
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]>
Acked-by: Etienne Carriere <[email protected]>
Acked-by: Jerome Forissier <[email protected]>

Fixed spacing

Signed-off-by: Julianus Larson <[email protected]>
@jforissier
Copy link
Contributor

Merged manually (with commit message slightly edited).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants