-
Notifications
You must be signed in to change notification settings - Fork 73
optee_teec: extension: fix macro errors #176
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DemesneGH
reviewed
Mar 25, 2025
|
Network Error, the pipeline pass on my fork: https://github.com/ivila/incubator-teaclave-trustzone-sdk/actions/runs/14073623792 |
|
Update: remove the unnessesary |
DemesneGH
reviewed
Mar 27, 2025
7fa7393 to
34d31ee
Compare
|
|
* Fix usage of Rust types as return values in FFI functions. * Standardize the function signature to require returning a Result. * Use inner functions in generated code to prevent unexpected early returns. * Fix example: supp_plugin-rs. Signed-off-by: Zehui Chen <ivila@apache.org> Reviewed-by: Yuan Zhuang <yuanz@apache.org>
|
Please feel free to rebase and merge once CI passed 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Fix usage of Rust types as return values in FFI functions.
https://github.com/apache/incubator-teaclave-trustzone-sdk/blob/cf0f662eec9213be32bf972888f422575b03bc7a/optee-teec/src/extension.rs#L23-L33
Currently, the plugin's methods use Rust's
optee_teec::Resultas the return value forFFI, which is incorrect since Rust does not guarantee a stable ABI. We need to change them tooptee_teec_sys::TEEC_Result(alias of u32) instead.Standardize the function signature to require returning a Result.
Similar to the original signatures of TEEC functions, we currently require the plugin's methods to return an error.
init: fromfn()tofn() -> optee_teec::Result<()>invoke_command: fromfn(&mut optee_teec::PluginParameters)tofn(&mut optee_teec::PluginParameters) -> optee_teec::Result<()>And in fact, the current examples of

supp_plugin-rsalready return a Result, even though this contradicts their function signatures.Use inner functions in generated code to prevent unexpected early returns.
Previous macros simply duplicated the code into the new function.
https://github.com/apache/incubator-teaclave-trustzone-sdk/blob/cf0f662eec9213be32bf972888f422575b03bc7a/optee-teec/macros/src/lib.rs#L60-L67
Which is buggy if developers have some return statements inside.
For example, if developer define a function:
It will be rewrite to: